Given a number n, write a program to check whether given number is Adam Number or not. Adam number is a number when reversed, the square of the number and the square of the reversed number should be numbers which are reverse of each other. Adam numbers upto 1000 are: 0, 1, 2, 3, 11, 12, 13, 21, 22, 31, 101, 102, 103, 111, 112 , 113, 121, 122, 201, 202, 211, 212, 221, 301, 311.
Input : 12
Output : Adam Number
Square of 12 = 144
Reverse of 12 = 21
Square of 21 = 441
Now Square of 12 and square of reverse of 12 are
reverse of each other. Therefore 12 is Adam number.
Input : 14
Output : Not a Adam Number
Steps to find Adam number :
Step 1: Find square of number.
Step 2: Find reverse of number.
Step 3: Find square of number in Step 2.
Step 4: Find reverse of number in Step 3.
Step 5: Find whether number obtained in Step 4 and Step 1 are equal or not.
This article is contributed by nuclode. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.