Reverse and Add Function | Iterative function to reverse digits of num ; Function to check whether the number is palindrome or not ; Reverse and Add Function ; Reversing the digits of the number ; Adding the reversed number with the original ; Checking whether the number is palindrome or not ; Driver Code
def reversDigits ( num ) : NEW_LINE INDENT rev_num = 0 NEW_LINE while ( num > 0 ) : NEW_LINE INDENT rev_num = rev_num * 10 + num % 10 NEW_LINE num = num / 10 NEW_LINE DEDENT return rev_num NEW_LINE DEDENT def isPalindrome ( num ) : NEW_LINE INDENT return ( reversDigits ( num ) == num ) NEW_LINE DEDENT def ReverseandAdd ( num ) : NEW_LINE INDENT rev_num = 0 NEW_LINE while ( num <= 4294967295 ) : NEW_LINE INDENT rev_num = reversDigits ( num ) NEW_LINE num = num + rev_num NEW_LINE if ( isPalindrome ( num ) ) : NEW_LINE INDENT print num NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT if ( num > 4294967295 ) : NEW_LINE INDENT print " No ▁ palindrome ▁ exist " NEW_LINE DEDENT DEDENT DEDENT DEDENT ReverseandAdd ( 195 ) NEW_LINE ReverseandAdd ( 265 ) NEW_LINE