Check if a given number is one less than twice its reverse | Iterative function to reverse digits of num ; Loop to extract all digits of the number ; Function to check if N satisfies given equation ; Driver Code
function rev ( num ) { var rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = parseInt ( num / 10 ) ; } return rev_num ; } function check ( n ) { return 2 * rev ( n ) == n + 1 ; } var n = 73 ; if ( check ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;