Given an integer, write a function todetermine if it is a power of three.
Follow up:
Could you do it without using any loop /recursion?
public class Solution {
public boolean isPowerOfThree(int n) {
double res = Math.log(n)/Math.log(3);
return Math.abs(res - Math.rint(res))<0.0000000001;
}
}