Check if a number is a power of another number | C # program to check given number y is power of x ; logarithm function to calculate value ; Note : this is double ; compare to the result1 or result2 both are equal ; Driver Code
using System ; class GFG { static bool isPower ( int x , int y ) { int res1 = ( int ) Math . Log ( y ) / ( int ) Math . Log ( x ) ; double res2 = Math . Log ( y ) / Math . Log ( x ) ; return ( res1 == res2 ) ; } static void Main ( ) { if ( isPower ( 27 , 729 ) ) Console . WriteLine ( "1" ) ; else Console . WriteLine ( "0" ) ; } }