Recursive program to check if number is palindrome or not | Recursive function that returns the reverse of digits ; base case ; stores the reverse of a number ; Driver Code
def rev ( n , temp ) : NEW_LINE INDENT if ( n == 0 ) : NEW_LINE INDENT return temp ; NEW_LINE DEDENT temp = ( temp * 10 ) + ( n % 10 ) ; NEW_LINE return rev ( n / 10 , temp ) ; NEW_LINE DEDENT n = 121 ; NEW_LINE temp = rev ( n , 0 ) ; NEW_LINE if ( temp != n ) : NEW_LINE INDENT print ( " yes " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " no " ) ; NEW_LINE DEDENT