FunctionRacerProblemsRace

Power of Three

BeginnerMathPython, JavaScript, TypeScript, Java, C++

Return True if n equals 3 raised to some whole number power (1, 3, 9, 27, ...), otherwise False. Zero and negative numbers do not count.

Example 1

n 27
returns true

3 cubed.

Example 2

n 45
returns false

45 = 9 * 5, not a power of three.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems