clueless coding // TODO: be smarter

LeetCode Power of Three: Java Solution



TL;DR Code Solution


public boolean isPowerOfThree(int n) {

    if (n < 1) {
        return false;
    }
    while (n % 3 == 0) {
        n /= 3;
    }
    return n == 1;


}