Skip to content
Onsite

Power of Three

EasyP3Coding

Given an integer n, return true if there is an integer k >= 0 such that n == 3^k, otherwise false.

Example 1

Input
n = 27
Output
true

Example 2

Input
n = 0
Output
false

Example 3

Input
n = 9
Output
true

Constraints

  • -2^31 <= n <= 2^31 - 1

Hints

Run checks the 3 visible tests, Submit all 10.