每日一题力扣342 啊这

给定一个整数,写一个函数来判断它是否是 4 的幂次方。如果是,返回 true ;否则,返回 false 。

整数 n 是 4 的幂次方需满足:存在整数 x 使得 n == 4x

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/power-of-four
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        while n>=4:
            n/=4
        return n==1
原文地址:https://www.cnblogs.com/liuxiangyan/p/14510932.html