DulcetAirman icon

multiple of two

DulcetAirman | PRO | 10/06/18 12:23:48 PM UTC | 0 ⭐ | 918 👁️ | Never ⏰ | []
Java |

260 B

|

None

|

0 👍

/

0 👎

    for (int x = 0; x < 100; x++) {
      boolean notZero = x != 0;
      int previous = x - 1;
      int and = x & previous;
      boolean isMultipleOfTwo = notZero && (and == 0);
      System.out.println(String.format("%d = %s", x, isMultipleOfTwo));
    }

Comments