26. Power of Three
# Easy
class Solution:
def isPowerOfThree(self, n: int) -> bool:
while n >= 3 and n%3 == 0:
n = n//3
if n == 1:
return True
else:
return False
Last updated
Was this helpful?