package leetcode;

/**
 * https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/
 */
public class Problem1780 {
    public boolean checkPowersOfThree(int n) {
        long sum = 0;
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1780 prob = new Problem1780();
        System.out.println(prob.checkPowersOfThree(1)); // false
        System.out.println(prob.checkPowersOfThree(2)); // false
        System.out.println(prob.checkPowersOfThree(3)); // true
        System.out.println(prob.checkPowersOfThree(4)); // true
        System.out.println(prob.checkPowersOfThree(5)); // false
        System.out.println(prob.checkPowersOfThree(6)); // false
        System.out.println(prob.checkPowersOfThree(7)); // false
        System.out.println(prob.checkPowersOfThree(8)); // false
        System.out.println(prob.checkPowersOfThree(9)); // true
        System.out.println(prob.checkPowersOfThree(10)); // true
        System.out.println(prob.checkPowersOfThree(11)); // false
        System.out.println(prob.checkPowersOfThree(12)); // true
        System.out.println(prob.checkPowersOfThree(13)); // true
        System.out.println(prob.checkPowersOfThree(14)); // false
        System.out.println(prob.checkPowersOfThree(15)); // false
        System.out.println(prob.checkPowersOfThree(16)); // false
        System.out.println(prob.checkPowersOfThree(17)); // false
        System.out.println(prob.checkPowersOfThree(18)); // false
        System.out.println(prob.checkPowersOfThree(19)); // false
        System.out.println(prob.checkPowersOfThree(20)); // false
        System.out.println(prob.checkPowersOfThree(21)); // false
        System.out.println(prob.checkPowersOfThree(22)); // false
        System.out.println(prob.checkPowersOfThree(23)); // false
        System.out.println(prob.checkPowersOfThree(24)); // false
        System.out.println(prob.checkPowersOfThree(25)); // false
        System.out.println(prob.checkPowersOfThree(26)); // false
        System.out.println(prob.checkPowersOfThree(27)); // true
        System.out.println(prob.checkPowersOfThree(28)); // true
        System.out.println(prob.checkPowersOfThree(29)); // false
        System.out.println(prob.checkPowersOfThree(30)); // true
        System.out.println(prob.checkPowersOfThree(91)); // true
    }
}

@@ -184,190 +184,15 @@
     
-long sum = 0;%0A        // TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1780 prob = new Problem1780();%0A        System.out.println(prob.
+return 
 chec
@@ -210,1459 +210,193 @@
 ree(
-1)); // false
+n, 1);
 %0A    
+%7D%0A%0A
     
-System.out.println(prob.checkPowersOfThree(2)); // false%0A        System.out.println(prob.checkPowersOfThree(3)); // true%0A        System.out.println(prob.checkPowersOfThree(4)); // true%0A        System.out.println(prob.checkPowersOfThree(5)); // false%0A        System.out.println(prob.checkPowersOfThree(6)); // false%0A        System.out.println(prob.checkPowersOfThree(7)); // false%0A        System.out.println(prob.checkPowersOfThree(8)); // false%0A        System.out.println(prob.checkPowersOfThree(9)); // true%0A        System.out.println(prob.checkPowersOfThree(10)); // true%0A        System.out.println(prob.checkPowersOfThree(11)); // false%0A        System.out.println(prob.checkPowersOfThree(12)); // true%0A        System.out.println(prob.checkPowersOfThree(13)); // true%0A        System.out.println(prob.checkPowersOfThree(14)); // false%0A        System.out.println(prob.checkPowersOfThree(15)); // false%0A        System.out.println(prob.checkPowersOfThree(16)); // false%0A        System.out.println(prob.checkPowersOfThree(17)); // false%0A        System.out.println(prob.checkPowersOfThree(18)); // false%0A        System.out.println(prob.checkPowersOfThree(19)); // false%0A        System.out.println(prob.checkPowersOfThree(20)); // false%0A        System.out.println(prob.checkPowersOfThree(21)); // false%0A        System.out.println(prob.checkPowersOfThree(22)); // false%0A        System.out.println(prob.checkPowersOfThree(23)); //
+private static boolean checkPowersOfThree(int n, int pow) %7B%0A        if (pow == n) %7B%0A            return true;%0A        %7D%0A        if (pow %3E n) %7B%0A            return
  false
+;
 %0A   
@@ -404,523 +404,96 @@
     
-System.out.println(prob.checkPowersOfThree(24)); // false%0A        System.out.println(prob.checkPowersOfThree(25)); // false%0A        System.out.println(prob.checkPowersOfThree(26)); // false%0A        System.out.println(prob.checkPowersOfThree(27)); // true%0A        System.out.println(prob.checkPowersOfThree(28)); // true%0A        System.out.println(prob.checkPowersOfThree(29)); // false%0A        System.out.println(prob.checkPowersOfThree(30)); // true%0A        System.out.println(prob.checkPowersOfThree(91)); // true
+%7D%0A        return checkPowersOfThree(n, pow * 3) %7C%7C checkPowersOfThree(n - pow, pow * 3);
 %0A   

Solve problem 1780