Answer to Question #277507 in Python for Evans Mulenga

Question #277507

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.

1
Expert's answer
2021-12-09T07:30:16-0500


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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS