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
PostgreSQLv16

Tu sa zobrazí výsledok spustenia kódu

Visible tests
1
Input
1
ExpectedTrue
2
Input
16
ExpectedTrue
3
Input
6
ExpectedFalse
4
Input
0
ExpectedFalse
5
Input
-8
ExpectedFalse
6
Input
7
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid