Power of Two
Powers of two appear everywhere in programming, from memory sizes to bits, masks, and array boundaries. Given a number n, return True if it is a power of two such as 1, 2, 4, 8, and so on. For n <= 0, return False.
Примеры
Ввод
1Вывод
TrueВвод
16Вывод
TrueВвод
6Вывод
FalseНужно реализовать
def is_power_of_two(n: int) -> bool:
Теги
math
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
1Expected
True2
Input
16Expected
True3
Input
6Expected
False4
Input
0Expected
False5
Input
-8Expected
False6
Input
7Expected
FalseFocus radio
Paused · SomaFM · Fluid