0

I'm trying to use recursion to check if a number is a power of another number or not. For example, is_power(9,3) should return True but is_power(10,3) returns False. This is what my code looks like so far:

def is_power(a,b):
    if a == b or a == 1:
        return True
    elif b == 0 or a % b != 0 or b == 1:
        return False
    elif a != b:
        x = a / b
        y = int(x)
        is_power(y,b)

However, the function keeps returning None if the function has to loop more than once and I have no idea why. Can anyone who knows how recursion works explain why?

0 Answers0