public class Solution {
public boolean isPowerOfFour(int num) {
//return ((num - 1) & num) == 0 && ( num - 1 ) % 3 == 0;
// x^n - 1的因式分解一定含有(x-1). 因为x = 1是 x^n - 1 = 0的一个根
return ((num - 1) & num) == 0 && (num & 0x55555555) != 0;
//The basic idea is from power of 2, We can use "n&(n-1) == 0" to determine if n is power of 2.
//0x55555555 is to get rid of those power of 2 but not power of 4
//so that the single 1 bit always appears at the odd position
}
}