Check if a number is a power of another number | PHP program to check given number number y ; logarithm function to calculate value ; Note : this is double ; compare to the result1 or result2 both are equal ; Driver Code
< ? php function isPower ( $ x , $ y ) { $ res1 = log ( $ y ) / log ( $ x ) ; $ res2 = log ( $ y ) / log ( $ x ) ; return ( $ res1 == $ res2 ) ; } echo isPower ( 27 , 729 ) ; ? >