342. Power of Four
Question
Given an integer
n, returntrueif it is a power of four. Otherwise, returnfalse.An integer
nis a power of four, if there exists an integerxsuch thatn == 4<sup>x</sup>.
Solution
递归,如果n小于等于零则返回false。
如果n等于1则返回true。
如果n可以除以4,则递归返回n/4。
Code
1 | class Solution { |
342. Power of Four
