Given an integer n, return true if it is a power of three. Otherwise, return false.

An integer n is a power of three, if there exists an integer x such that n == 3x.

&nbsp;
Example 1:

Input: n = 27
Output: true


Example 2:

Input: n = 0
Output: false


Example 3:

Input: n = 9
Output: true


&nbsp;
Constraints:


	-231 &lt;= n &lt;= 231 - 1


&nbsp;
Follow up: Could you solve it without loops/recursion?
class Solution:
    def isPowerOfThree(self, n: int) -> bool:
        return round(log(n,3), 9) == round(log(n,3)) if n >= 1 else False
class Solution {
    public boolean isPowerOfThree(int n) {
       if(n==1){
            return true;
        }
        if(n<=0){
            return false;
        }
        if(n%3 !=0 && n>1){
            return false;
        }
        else{
            return isPowerOfThree(n/3); // recurssion 
        }
    }
}
class Solution {
public:
	bool isPowerOfThree(int n) {
		if(n<=0){return false;}
		if(n>pow(2, 31)-1 || n<pow(2, 31)*(-1)){return false;}
		return 1162261467%n==0;
	}
};
var isPowerOfThree = function(n) {
    if(n === 1){return true;}
    if(n === 0){return false;}

    n/=3;

    if(n%3 != 0 && n != 1){
        return false;
    }else{
        let x = isPowerOfThree(n);
        return x;
    }
};
Power of Three