Problem Solving
25. Power of Four
굥깡
2022. 9. 15. 04:21
728x90
https://leetcode.com/problems/power-of-four/
Power of Four - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
4의 제곱수가 맞는지 boolean으로 출력하는 문제
class Solution:
def isPowerOfFour(self, n: int) -> bool:
if n < 1:
return False
elif n == 1:
return True
while n > 1:
if n % 4 != 0:
return False
n = n // 4
return True
살짝 까다로운 듯했으나 금방 풀 수 있었던 문제