Adam Number | To reverse Digits of numbers ; To square number ; To check Adam Number ; Square first number and square reverse digits of second number ; If reverse of b equals a then given number is Adam number ; Driver program to test above functions
def reverseDigits ( num ) : NEW_LINE INDENT rev = 0 NEW_LINE while ( num > 0 ) : NEW_LINE INDENT rev = rev * 10 + num % 10 NEW_LINE num /= 10 NEW_LINE DEDENT return rev NEW_LINE DEDENT def square ( num ) : NEW_LINE INDENT return ( num * num ) NEW_LINE DEDENT def checkAdamNumber ( num ) : NEW_LINE INDENT a = square ( num ) NEW_LINE b = square ( reverseDigits ( num ) ) NEW_LINE if ( a == reverseDigits ( b ) ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT num = 13 NEW_LINE if ( checkAdamNumber ( num ) ) : NEW_LINE INDENT print " Adam ▁ Number " NEW_LINE DEDENT else : NEW_LINE INDENT print " Not ▁ a ▁ Adam ▁ Number " NEW_LINE DEDENT