Check if a given number is one less than twice its reverse | Function to check y is a power of x ; logarithm function to calculate value ; Compare to the result1 or result2 both are equal ; Function to check if N satisfies the equation 2 * reverse ( n ) = n + 1 ; Driver code
function isPower ( x , y ) { let res1 = Math . log ( y ) / Math . log ( x ) ; let res2 = Math . log ( y ) / Math . log ( x ) ; return ( res1 == res2 ) ; } function check ( n ) { let x = ( n + 7 ) / 8 ; if ( ( n + 7 ) % 8 == 0 && isPower ( 10 , x ) ) return true ; else return false ; } let n = 73 ; if ( check ( n ) != 0 ) document . write ( " " ) ; else document . write ( " " ) ;