dsa · easy

Power of Three

Return whether n is a positive power of three (1, 3, 9, 27, …).

Arguments

Example

n = 27true. n = 0false. n = 9true.

Constraints

-2^31 <= n <= 2^31 - 1 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
27

Expected:
true

Example 2

Input:
0

Expected:
false

Example 3

Input:
9

Expected:
true

Open in the Dojo editor