A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is power of b.
def is_power(a,b):
if (a % b == 0):
return True
if (a/b == 1):
return True
else:
(is_power (a/b, b) )
else:
return False
Comments
Leave a comment