Function to calculate and return the reverse of the number
function reverse ( num ) { var rev = 0 ; while ( num > 0 ) { var r = parseInt ( ( num % 10 ) ) ; rev = rev * 10 + r ; num = parseInt ( num / 10 ) ; } return rev ; }