Adam Number | To reverse Digits of numbers ; To square number ; To check Adam Number ; Square first number and square reverse digits of second number ; If reverse of b equals a then given number is Adam number ; Driver code
function reverseDigits ( num ) { let rev = 0 ; while ( num > 0 ) { rev = rev * 10 + num % 10 ; num = parseInt ( num / 10 , 10 ) ; } return rev ; } function square ( num ) { return ( num * num ) ; } function checkAdamNumber ( num ) { let a = square ( num ) ; let b = square ( reverseDigits ( num ) ) ; if ( a == reverseDigits ( b ) ) return true ; return false ; } let num = 12 ; if ( checkAdamNumber ( num ) ) document . write ( " " ) ; else document . write ( " " ) ;