bool isPowerOfTwo(int n){ for (int i=0; i<31 && pow(2,i)<=n; i++) { if (pow(2,i) == n) return true; } return false; }
bool isPowerOfTwo(int n){ return ((n > 0) && (n & (n - 1)) == 0); }