A digital art collective starts every new piece as a single square canvas panel. Whenever they choose to subdivide, every existing panel on the canvas is simultaneously split into exactly four equal quarter-panels, so after k whole subdivision rounds (k >= 0) a canvas that started as one panel now has exactly 4^k panels in total. Given the number of panels currently on a canvas, determine whether that count could have arisen from starting at one panel and applying this quadrupling subdivision some whole number of times (zero or more).
A single line containing one integer n.
Print true if n panels could result from applying the quadrupling subdivision to a single starting panel zero or more whole times (that is, n equals 4 raised to some non-negative integer power), and false otherwise.
Example 1
Input
16
Expected
true
Explanation
16 = 4 * 4 = 4^2, so it can arise after exactly 2 subdivision rounds starting from a single panel. The answer is true.
Example 2
Input
5
Expected
false
Explanation
5 is not any power of 4 (the nearest powers of 4 are 4 and 16), so no whole number of subdivision rounds produces exactly 5 panels. The answer is false.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →