diff --git a/src/main/java/com/bytelegend/Challenge.java b/src/main/java/com/bytelegend/Challenge.java index 20239d5..7eb218c 100644 --- a/src/main/java/com/bytelegend/Challenge.java +++ b/src/main/java/com/bytelegend/Challenge.java @@ -17,7 +17,7 @@ public static void main(String[] args) { * (`+`). */ public static int multiplyBy31(int n) { - return 0; + return (n << 5) - n; } /** @@ -32,6 +32,10 @@ public static int multiplyBy31(int n) { * addition sign (`+`). */ public static int divideBy2ThenMinus1(int n) { - return 0; + if (n < 0) { + int m = -n; + return -(m >> 1) - 1; + } + return (n >> 1) - 1; } }