n. Return True if n can be written as a sum of **distinct** powers of three (1, 3, 9, 27, …, each used at most once), and False otherwise.n=31 → True
31 = 27 + 3 + 1 = 3³ + 3¹ + 3⁰.
n=15 → False
15 = 9 + 3 + 3, but 3 cannot be used twice, and there is no other way.
n=1 → True
1 = 3⁰.
n=31
True
Run checks the first 3 tests in your browser. Submit checks all 109 tests on the server, hidden ones included.