DEV Community

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

isPowerOfThree

var isPowerOfThree = function(n) {
   return checkIsPower(n);

};

const checkIsPower = (n) =>{
    if(n<=0){
        return false;
    };
     if(n % 3 === 0){
        return checkIsPower(n/3)
    } 
    if(n==1){
        return true;
    };  
    return false;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)