Skip to content

Commit

Permalink
Update Challenge.java
Browse files Browse the repository at this point in the history
  • Loading branch information
VacancyIF authored Nov 23, 2023
1 parent e24cfc0 commit c40ee97
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main/java/com/bytelegend/Challenge.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

public class Challenge {
public static void main(String[] args) {
System.out.println(multiplyBy31(0));
System.out.println(multiplyBy31(1));
System.out.println(multiplyBy31(5));
System.out.println(divideBy2ThenMinus1(1));
System.out.println(divideBy2ThenMinus1(4));
System.out.println(divideBy2ThenMinus1(7));
// System.out.println(multiplyBy31(0));
// System.out.println(multiplyBy31(2));
// System.out.println(multiplyBy31(5));
System.out.println(-97 / 2 - 1);
System.out.println(-99 / 2 - 1);
System.out.println(-98 / 2 - 1);
System.out.println(divideBy2ThenMinus1(-97));
System.out.println(divideBy2ThenMinus1(-99));
System.out.println(divideBy2ThenMinus1(-98));
}

/**
Expand All @@ -17,7 +20,7 @@ public static void main(String[] args) {
* (`+`).
*/
public static int multiplyBy31(int n) {
return 0;
return (n << 5) - n;
}

/**
Expand All @@ -32,6 +35,6 @@ public static int multiplyBy31(int n) {
* addition sign (`+`).
*/
public static int divideBy2ThenMinus1(int n) {
return 0;
return ((n+1) >> 1 )- 1;
}
}

0 comments on commit c40ee97

Please sign in to comment.