Power of One Number by Another Check

  • Share this:

Code introduction


Determine if one number is a power of another


Technology Stack : Recursion

Code Type : Recursive function

Code Difficulty : Intermediate


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