**Solution**

**Power of Three** https://leetcode.com/problems/power-of-three/

**Algorithm**

- Iterative solution - repeatedly divide by 3.

```
class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
if n == 0:
return False
while n % 3 == 0:
n = n/3
return n == 1
```

**Algorithm**

- Find the maximum power of 3 just less than max_32bit_int. How? 3^y = 2^31 -1. Take log and find y and then find 3^y.
- 3^y % n must be zero

**List of solutions**