I wrote a simple recursive function to test whether a is a power of b.
def is_power(a, b):
""" returns True if a is a power of b"""
if a == b:
print('True!')
return True
elif a%b != 0:
return False
elif a != b and a%b == 0:
is_power(a/b, b)
When I run it on a case that should return True, it doesn't return anything, even though it executes other commands from the same if statement as the return statement.
is_power(8,2) True!
I assume I'm doing something stupid / missing something blindingly obvious. Can anyone help?
The last alternative is missing 'return'