Checking if One Number is a Power of Another

  • Share this:

Code introduction


Determine if one number is a power of another


Technology Stack : math

Code Type : Mathematical calculation function

Code Difficulty :


                
                    
def a_is_power_of_b(a, b):
    if a < b:
        return False
    while a % b == 0:
        a = a // b
    return a == 1                
              
Tags: