342 Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example:
Given num = 16, return true. Given num = 5, return false.
Follow up: Could you solve it without loops/recursion?
思路
可以通过循环或者递归的方法求出。
|
|
也可以利用位运算的方法。
|
|
得到一个判断条件
|
|
如果满足这个判断条件,就是四的乘方了。