.
Anonymous
plain_text
02/28/2024 7:17 AM
276 B
15
Indexable
def is_power_of_b(a, b):
if a == 0:
return False
while a % b == 0:
a /= b
return a == 1
# Example usage:
print(is_power_of_b(27, 3)) # True
print(is_power_of_b(28, 3)) # False
Editor is loading...
Leave a Comment