.

Anonymous
Plain Text
02/28/2024 7:17 AM
207 B
18
Indexable
Never
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