Easy understood java solution without recursion

  • -1
    public boolean isPowerOfThree(int n) {
        if(n <=0)
            return false;
            return true;
        long x =1;
        while(x < n){
            x *= 3;
        return x==n;

  • 0

    but you used loop.
    Could you do it without using any loop / recursion?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.