Power of Two
Source code Read on Github
1 public class Solution {
2 public boolean isPowerOfTwo(int n) {
3 if(n == 0) return false;
4 if(n == 1) return true;
5
6 if(n % 2 == 1) return false;
7
8 return isPowerOfTwo(n / 2);
9 }
10 }