Adam Number in JavaIn this section, we will learn what is an Adam number and also create Java programs to check if the given number is Adam or not. The Adam number program frequently asked in Java coding tests and academics. Adam NumberA number is called an Adam number if the square of a number and the square of its reverse are reverse to each other. Let's understand it through an example. Adam Number ExampleConsider a number (N) 12 and check it is an Adam number or not. Square of the number (N) = 144 The reverse of the number (N) = 21 Square of the reverse of the number (N) = 441 We observe that the square of 12 and the square of its reverse i.e. 21 are reverse of each other. Hence, 12 is an Adam number. Some other Adam numbers are 0, 1, 2, 3, 11, 12, 13, 21, 22, 31, 101, 102, 103, 111, etc. Steps to Find Adam Number
Let's implement the above steps in a Java program. Adam Number Java ProgramAdamNumberExample1.java Output 1: Enter the number: 301 301 is an Adam number. Output 2: Enter the number: 276 276 is not an Adam number. Let's create another Java program and find all the prime Adam numbers between the given range. PrimeAdamExample.java Output: Enter the lower limit: 0 Enter the upper limit: 1000 The prime Adam numbers are: 2 3 11 13 31 101 103 113 211 311 Frequency of Adam number is: 10
Next TopicBell Number in Java
|