Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 330 Bytes

326. Power of Three.md

File metadata and controls

16 lines (12 loc) · 330 Bytes

326. Power of Three

Power of Three - LeetCode

class Solution {
    public boolean isPowerOfThree(int n) {
        if(n <= 0) return false;

       while(n > 1 && (n % 3) == 0 ) 
            n /= 3;

        return (n == 1 || n % 3 == 0)? true : false; 
    }
}