Power of Three
Given an integer, write a function to determine if it is a power of three.
Example 1:
1 | Input: 27 |
Example 2:
1 | Input: 0 |
Example 3:
1 | Input: 9 |
Example 4:
1 | Input: 45 |
Follow up:
Could you do it without using any loop / recursion?
思路:首先能想到的肯定是循环或者递归。代码如下:
1 | class Solution { |