Java One Line: return n > 0 && (Math.log10(n) / Math.log10(3)) % 1 == 0;


  • 0
    B
    public class Solution {
        public boolean isPowerOfThree(int n) {
            return n > 0 &&  (Math.log10(n) / Math.log10(3)) % 1 == 0;
        }
    }
    

Log in to reply
 

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