Reversible numbers | Function to check reversible number ; Calculate reverse of n ; Calculate sum of number and its reverse ; Check for reverse number reach digit must be odd ; Driver Code
def checkReversible ( n ) : NEW_LINE INDENT rev = 0 NEW_LINE flag = n NEW_LINE while ( flag != 0 ) : NEW_LINE INDENT rem = flag % 10 NEW_LINE rev *= 10 NEW_LINE rev += rem NEW_LINE flag //= 10 NEW_LINE DEDENT sum = rev + n NEW_LINE while ( sum and ( ( rem % 2 ) != 0 ) ) : NEW_LINE INDENT rem = sum % 10 NEW_LINE sum //= 10 NEW_LINE DEDENT if ( sum == 0 ) : NEW_LINE INDENT print ( " Reversible ▁ Number " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " Non - Reversible ▁ Number " ) NEW_LINE DEDENT DEDENT n = 36 NEW_LINE checkReversible ( n ) NEW_LINE