leedcode-4的幂

自己写的,如果n对4可以整除。就让n除以4,循环往复

class Solution:
    def isPowerOfFour(self, n: int) -> bool:
        while n%4==0 and n>0:
            n//=4

        return n==1

 

posted @ 2024-04-08 09:29  Junior_bond  阅读(10)  评论(0)    收藏  举报