Power of Three
Powers of 3 are numbers like 1, 3, 9, 27, and so on. Given an integer n, return True if it can be written as 3^k, where k is a non-negative integer. In all other cases, return False.
Примеры
Ввод
27Вывод
TrueВвод
0Вывод
FalseВвод
9Вывод
TrueНужно реализовать
def is_power_of_three(n: int) -> bool:
Теги
math
Inicia sesión para ver tu historial de envíos
Iniciar sesiónInicia sesión para usar el AI Mentor
Iniciar sesiónVisible tests
1
Input
27Expected
True2
Input
0Expected
False3
Input
9Expected
True4
Input
45Expected
False5
Input
1Expected
True6
Input
3Expected
TrueFocus radio
Paused · SomaFM · Fluid