"""Leetcode 326. Power of Three
Easy

URL: https://leetcode.com/problems/power-of-three/

Given an integer, write a function to determine if it is a power of three.

Example 1:
Input: 27
Output: true

Example 2:
Input: 0
Output: false

Example 3:
Input: 9
Output: true

Example 4:
Input: 45
Output: false

Follow up:
Could you do it without using any loop / recursion?
"""

class Solution(object):
    def isPowerOfThree(self, n):
        """
        :type n: int
        :rtype: bool
        """
        pass


def main():
    pass


if __name__ == '__main__':
    main()

@@ -381,16 +381,21 @@
 Solution
+While
 (object)
@@ -487,55 +487,524 @@
 ool%0A
-        %22%22%22%0A        pass%0A%0A%0Adef main():%0A    pass
+%0A        Time complexity: O(logn).%0A        Space complexity: O(1).%0A        %22%22%22%0A        while n %3E 1:%0A            n /= 3.0%0A%0A        if n == 1:%0A            return True%0A        else:%0A            return False%0A%0A%0Adef main():%0A    # Output: True%0A    n = 27%0A    print SolutionWhile().isPowerOfThree(n)%0A%0A    # Output: False%0A    n = 0%0A    print SolutionWhile().isPowerOfThree(n)%0A%0A    # Output: True%0A    n = 9%0A    print SolutionWhile().isPowerOfThree(n)%0A%0A    # Output: False%0A    n = 45%0A    print SolutionLoop().isPowerOfThree(n)%0A
 %0A%0A%0Ai

Complete while loop sol