public class Solution {
public bool IsPowerOfThree(int n) {
return n > && ( % n == );
}
}
https://leetcode.com/problems/power-of-three/#/description
使用循环实现,python
class Solution:
def isPowerOfThree(self, n: int) -> bool:
while n > and n % == :
n = n //
return n ==