DEV Community

Discussion on: Solution: Power of Three

Collapse
 
rohithv07 profile image
Rohith V

Here is my attempt on this problem :

class Solution {
    public boolean isPowerOfThree(int n) {
        if (n == 0)
            return false;
        return (Math.log10(n) / Math.log10(3)) % 1 == 0;
    }
}
Enter fullscreen mode Exit fullscreen mode

Leetcode Daily Challenge + Other resources