Given an integer, write a function to determine if it is a power of three.
Follow up:
Could you do it without using any loop / recursion?
Solution
- Java:Find the maximum integer(1162261467) that is a power of 3 and check if it is a multiple of the given input.
1 2 3 4 5 |
|
- Python: 求对数,然后乘方,判断得数是否相等
1 2 3 4 5 6 7 8 |
|