Here’s a code for the program using recursion,
“Given an integer n, return true if it is a power of three. Otherwise, return false.”
class Solution:
def isPowerOfThree(self, n: int) -> bool:
if(n>0):
if(n == 1 or n == 3): return True
elif(n%3 != 0): return False
else: self.isPowerOfThree(n/3)
else: return False
this code when run in vs code passes all the test cases, while when run in Leetcode fails the test case of “27”.
How is this possible? or does Leetcode compiler behaves differently?
would be grateful if someone helped me out here