Skip to content

Commit 84be70d

Browse files
Create 231. Power of Two
1 parent 7278350 commit 84be70d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

231. Power of Two

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def isPowerOfTwo(self, n: int) -> bool:
3+
if n == 0:
4+
return False
5+
else:
6+
while n != 1:
7+
if n%2 != 0:
8+
return False
9+
n = n//2
10+
return True

0 commit comments

Comments
 (0)