Algorithm
powerOfTwo // Java
public boolean powerOfTwo(long num) { while (num >= 1) { num = num / 2; if (num == 1) { return true; } else if (num % 2 > 0) { return false; } } return true; }
public boolean powerOfTwo(long num) { while (num >= 1) { num = num / 2; if (num == 1) { return true; } else if (num % 2 > 0) { return false; } } return true; }