描述
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?
分析
和那道2的n次幂,用log函数即可。
解决方案1(C++)
1 | class Solution { |
相关问题
(E) Power of Two
(E) Power of Three