class Solution: def isPowerOfThree(self, n: int) -> bool: last=1 while last