Power of Another Number Python

PROGRAM TO CHECK IF A NUMBER IS POWER OF ANOTHER NUMBER


import math
def isPower(x, y):
    # logarithm function to
    # calculate value
    res1 = math.log(y) // math.log(x);
      
    # Note : this is double
    res2 = math.log(y) / math.log(x); 
  
    # compare to the result1 or
    # result2 both are equal
    return 1 if(res1 == res2) else 0;
  
# Driver Code
if __name__=='__main__':
    print(isPower(27, 729));


OUTPUT
1

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java