Question

# Check whether a number is Prime Adam number or not.

## (Prime Adam number is a prime number whose square of the number and the square of the reversed number should be reverse to each other)

```				```
Enter the number:
13
13 IS A PRIME NUMBER
SQUARE OF 13 IS :169
REVERSE OF 13 IS :31
SQUARE OF REVERSE OF NUMBER(31) IS :961
REVERSE OF 961 IS :169
SQUARE OF NUMBER IS EQUAL TO REVERSE OF SQUARE OF REVERSED NUMBER THEREFORE,

Enter the number:
19
19 IS A PRIME NUMBER
SQUARE OF 19 IS :361
REVERSE OF 19 IS :91
SQUARE OF REVERSE OF NUMBER(91) IS :8281
REVERSE OF 8281 IS :1828
SQUARE OF NUMBER IS NOT EQUAL TO REVERSE OF SQUARE OF REVERSED NUMBER THEREFORE,
19 IS NOT AN ADAM NUMBER
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
{
public static void main()
{
int temp=0,rem=0,i=0;
boolean isPrime=true;
int num,squareOfNum=0,reverseOfNum=0,squareOfReverseOfNum=0,reverseOfSquaredReverseNumber=0;
//num variable will store the number which we will take from user
//squareOfNum variable will store the square of variable num
//reverseOfNum variable will store the reverse of the number
//squareOfReverseOfNum will store square of reverseOfNum variable
// and reverseOfSquaredReverseNumber will store the reverse of variable squareOfReverseOfNum

Scanner sc=new Scanner(System.in);
System.out.println("Enter the number:");
num=sc.nextInt();
temp=num;
if(num<=1)
{
System.out.println(num+" IS NOT A PRIME NUMBER,THEREFORE IT IS NOT PRIME ADAM NUMBER");
}
else
{
//Checking if given number is Prime number or not
for(i=2;i< num;i++)
{
if(num%i==0)
{
System.out.println("GIVEN NUMBER IS NOT A PRIME NUMBER,THEREFORE IT IS NOT PRIME ADAM NUMBER");
isPrime=false;
break;
}
}
if(isPrime==true)
{
temp=num;
//Finding the reverse of number
while(temp>0)
{
rem=temp%10;
reverseOfNum=reverseOfNum*10+rem;
temp=temp/10;
}
squareOfNum=num*num;
squareOfReverseOfNum=reverseOfNum*reverseOfNum;
temp=squareOfReverseOfNum;
//Finding the reverse of square of reversed number
while(temp>0)
{
rem=temp%10;
reverseOfSquaredReverseNumber=reverseOfSquaredReverseNumber*10+rem;
temp=temp/10;
}

if(reverseOfSquaredReverseNumber==squareOfNum)
{
//the first six lines in this if condition can be removed
//it is only for making it easier to understand
System.out.println(num+" IS A PRIME NUMBER");
System.out.println("SQUARE OF "+num+" IS :"+squareOfNum);
System.out.println("REVERSE OF "+num+" IS :"+reverseOfNum);
System.out.println("SQUARE OF REVERSE OF NUMBER("+reverseOfNum+") IS :"+squareOfReverseOfNum);
System.out.println("REVERSE OF "+squareOfReverseOfNum+" IS :"+reverseOfSquaredReverseNumber);
System.out.println("SQUARE OF NUMBER IS EQUAL TO REVERSE OF SQUARE OF REVERSED NUMBER THEREFORE,");
}
else
{
//the first six lines in this else condition can be removed
//it is only for making it easier to understand
System.out.println(num+" IS A PRIME NUMBER");
System.out.println("SQUARE OF "+num+" IS :"+squareOfNum);
System.out.println("REVERSE OF "+num+" IS :"+reverseOfNum);
System.out.println("SQUARE OF REVERSE OF NUMBER("+reverseOfNum+") IS :"+squareOfReverseOfNum);
System.out.println("REVERSE OF "+squareOfReverseOfNum+" IS :"+reverseOfSquaredReverseNumber);
System.out.println("SQUARE OF NUMBER IS NOT EQUAL TO REVERSE OF SQUARE OF REVERSED NUMBER THEREFORE,");
System.out.println(num+" IS NOT AN ADAM NUMBER");
}
}

}
}
}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50