An authentic Adam Number program
Adam Number program: solved Java program for ISC Class 12 Computer Science with complete BlueJ code, explanation and sample output.
A number is said to be adam number if a number is squared and reversed and then its root is found out and again reversed and hence if the number obtained is same as the initial number then its is called an adam number.
Adam numbers up to 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.
Click here for java videos
import java.io.*;
class Adam
{
static int rev(int num)
{
int rev=0;
while(num!=0)
{
int rem=num%10;
rev=rev*10+rem;
num=num/10;
}
return rev;
}
static int sq(int a)
{
int sq_a=a*a;
return sq_a;
}
static boolean isAdam(int b)
{
int b_sq=sq(b); //square of real num
int rev_b=rev(b); //reverse of real num
int sq_rev=sq(rev_b); //square of reversed num
int rev_sq=rev(sq_rev); //reverse of the square of the reversed num
if(b_sq==rev_sq)
{
return true;
}
else
{
return false;
}
}
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("ENTER THE RANGE");
System.out.println("ENTER LOWER LIMIT");
int m=Integer.parseInt(br.readLine());
System.out.println("ENTER UPPER LIMIT");
int n=Integer.parseInt(br.readLine());
int freq=0;
if(m<n)
{
System.out.println("THE ADAM INTEGERS ARE:");
for(int i=m;i<=n;i++)
{
if(isAdam(i)==true)
{
System.out.print(i+"\t");
freq++;
}
}
System.out.println();
System.out.println("FREQUENCY OF ADAM INTEGERS IS: "+freq); }
else
{
System.out.println("INVALID RANGE");
}
}
}Output:
ENTER THE RANGE
ENTER LOWER LIMIT
100
ENTER UPPER LIMIT
200
THE ADAM INTEGERS ARE:
101 102 103 111 112 113 121 122
FREQUENCY OF ADAM INTEGERS IS: 8
Keith Number
Related Posts
Continue learning with these related articles

ISC Practical 2027: Image Editor – Brighten an Image and Find Bright Spots (2-D Array) – Java Program
Fully solved ISC Computer Science Practical 2027 2-D array question: brighten a grayscale image (capping values at 255) and find the bright spots, pixels larger than all four neighbours. Includes a missing bright spot in CISCE’s sample output.

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.