Lychrel Number Implementation | Max Iterations ; Function to check whether number is Lychrel Number ; Function to check whether the number is Palindrome ; Function to reverse the number ; driver program
var MAX_ITERATIONS = 20 ; function isLychrel ( number ) { for ( var i = 0 ; i < MAX_ITERATIONS ; i ++ ) { number = number + reverse ( number ) ; if ( isPalindrome ( number ) ) return false ; } return true ; } function isPalindrome ( number ) { return number == reverse ( number ) ; } function reverse ( number ) { var reverse = 0 ; while ( number > 0 ) { var remainder = number % 10 ; reverse = ( reverse * 10 ) + remainder ; number = parseInt ( number / 10 ) ; } return reverse ; } var number = 295 ; document . write ( number + " " + isLychrel ( number ) ) ;