LeetCode 솔루션					분류
				
						[8/24] 326. Power of Three
본문
Easy
1314146Add to ListShareGiven an integer n, return true if it is a power of three. Otherwise, return false.
An integer n is a power of three, if there exists an integer x such that n == 3x.
Example 1:
Input: n = 27 Output: true
Example 2:
Input: n = 0 Output: false
Example 3:
Input: n = 9 Output: true
Constraints:
- -231 <= n <= 231 - 1
Follow up: Could you solve it without loops/recursion?
Accepted
509,082
Submissions
1,158,014
				태그
				#Amazon			
			관련자료
- 
			링크
			댓글 1
					
			학부유학생님의 댓글
- 익명
- 작성일
					
										
					Runtime: 134 ms, faster than 50.88% of Python3 online submissions for Power of Three.
Memory Usage: 13.9 MB, less than 57.97% of Python3 online submissions for Power of Three.
				
													
								Memory Usage: 13.9 MB, less than 57.97% of Python3 online submissions for Power of Three.
class Solution:
    def isPowerOfThree(self, n: int) -> bool:
        if n == 1: return True
        if n < 1: return False
        
        while n > 1 and n%3 == 0:
            n /= 3
            
        return True if n == 1 else False 
								 
							







