Given an integer, write a function to determine if it is a power of three.
Example
No.1
Input: 27
Output: true
No.2
Input: 0
Output: false
No.3
Input: 9
Output: true
No.4
Input: 45
Output: false
Follow up
Could you do it without using any loop / recursion?
Code
1 | public boolean isPowerOfThree(int n) { |