# if not then print the number which are power of 3 below the entered number
def isPowerOfThree(n):
if n == 0:
return False
while n > 1:
if n % 3 != 0:
return False
n = n//3
return True
n = int(input("Enter the number : "))
if isPowerOfThree(n):
print(n, "is a power of three")
else:
data = []
add = 0
for j in range(1, n):
if isPowerOfThree(j):
data.append(j)
else:
pass
print(data, "are powers of three less than the number")
# Coded By Dhiraj Shelke
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP