LeetCode 326_ 3的幂

1. 题目描述

 

2. 代码

1 class Solution:
2     def isPowerOfThree(self, n: int) -> bool:
3         while n > 2 and n % 3 == 0:
4             n = n // 3
5         return n == 1

 

posted @ 2020-10-20 20:51  vv_869  阅读(57)  评论(0编辑  收藏  举报