Given a whole number n, check if it is a power of three.
A number is a power of three when it equals 3 multiplied by itself some number of times (zero times is allowed, so 1 counts). So 1, 3, 9, 27 and 81 are powers of three.
Answer true when n is a power of three, and false when it is not.
Examples
Example 1:
Input: n = 81
Output: true
Explanation: 81 = 3 x 3 x 3 x 3.
Example 2:
Input: n = 18
Output: false
Explanation: 18 is 2 x 9. It is not made only of threes.
Example 3:
Input: n = 1
Output: true
Explanation: 3 used zero times gives 1.