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?
public class Solution {
public boolean isPowerOfThree(int n) {
if(n<1) return false;
while(n>2)
{
if((n%3)==1||(n%3)==2) return false;
else n=n/3;
}
if(n==1) return true;
else return false;
}
}