```
public boolean isPowerOfThree(int n) {
if(n>0){
//this calculates log(n) to the base 3 == log(n)/log(3)
double numerator = Math.log(n);
double denom = Math.log(3);
int value = (int) Math.round(numerator/denom);
//raise the result of log to 3 and it should equal n
if(Math.pow(3,value)==n)
return true;
}
return false;
}
```