Advertisement
DulcetAirman

multiple of two

Oct 6th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  1.     for (int x = 0; x < 100; x++) {
  2.       boolean notZero = x != 0;
  3.       int previous = x - 1;
  4.       int and = x & previous;
  5.       boolean isMultipleOfTwo = notZero && (and == 0);
  6.       System.out.println(String.format("%d = %s", x, isMultipleOfTwo));
  7.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement