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 Explanation: 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 contribute.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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find Prime Adam integers in the given range [L, R]
- Number of factors of very large number N modulo M where M is any prime number
- Count number of triplets with product equal to given number with duplicates allowed
- Find the largest number smaller than integer N with maximum number of set bits
- Count number of trailing zeros in Binary representation of a number using Bitset
- Find minimum number to be divided to make a number a perfect square
- Number of distinct ways to represent a number as sum of K unique primes
- Smallest number dividing minimum number of elements in the Array
- Smallest number dividing minimum number of elements in the array | Set 2
- Largest number dividing maximum number of elements in the array
- Minimum divisor of a number to make the number perfect cube
- Find smallest possible Number from a given large Number with same count of digits
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Minimum number of swaps required to make a number divisible by 60
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Previous perfect square and cube number smaller than number N
- Given number of matches played, find number of teams in tournament
- Find the minimum number to be added to N to make it a prime number
- Number of times the largest perfect square number can be subtracted from N
- Number of ways to split a binary number such that every part is divisible by 2