<jupyter_start><jupyter_text>Given an integer, write a function to determine if it is a power of three.Example 1:    Input: 27    Output: trueExample 2:    Input: 0    Output: falseExample 3:    Input: 9    Output: trueExample 4:    Input: 45    Output: falseFollow up:- Could you do it without using any loop / recursion? - [Math 1-liner, no log, with explanation](https://leetcode.com/problems/power-of-three/discuss/77977/Math-1-liner-no-log-with-explanation)> The positive divisors of 3^19 are exactly the powers of 3 from 3^0 to 3^19. That's all powers of 3 in the possible range here (signed 32-bit integer). So just check whether the number is positive and whether it divides 3^19.2 ^ 20 = 2147483648   3 ^ 19 = 1162261467<jupyter_code>class Solution:
    def isPowerOfThree(self, n: int) -> bool:
        return n > 0 == 3 ** 19 % n
    
# test
n = 27
Solution().isPowerOfThree(n)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09803921568627451, 'fraction_numerical': 0.06971677559912855, 'mean_word_length': 3.688775510204082, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '253996', 'license': 'MIT', 'n_tokens_mistral': 345, 'n_tokens_neox': 285, 'n_words': 113, 'path': 'DSA/math/isPowerOfThree.ipynb', 'repo_name': 'lance-lh/Data-Structures-and-Algorithms', 'size': '918'}