# Prime Adam Integer – ISC 2020 Computer Practical Question 1

Prime-Adam integer is a positive integer (without leading zeroes) which is a prime as well as an Adam number.

Prime number: A number which has only two factors, i.e. 1 and the number itself. Example: 2, 3, 5, 7, etc.

Adam number: The square of a number and the square of its reverse are reverse to each other. Example: If n = 13 and reverse of ‘n’ is 31, then, 132 = 169, and 312 = 961 which is reverse of 169. Thus, 13 is an Adam number.

Accept two positive integers m and n, where m is less than n as user input. Display all Prime-Adam integers that are in the range between m and n (both inclusive) and output them along with the frequency, in the format given below:

Test your program with the following data and some random data:

Example 1:
INPUT:
m = 5
n = 100
OUTPUT:
11, 13, 31
Frequency of Prime-Adam integers is: 3

Example 2:
INPUT:
m = 100
n = 200
OUTPUT:
101, 103, 113
Frequency of Prime-Adam integers is: 3

Example 3:
INPUT:
m = 50
n = 70
OUTPUT:
NIL
Frequency of Prime-Adam integers is: 0

Example 4:
INPUT:
m = 700
n = 450
OUTPUT:
Invalid Input.

```import java.util.Scanner;
{
boolean isPrime(int n)
{
int c=0;
for(int i=1; i<=n; i++)
{
if(n%i==0)
c++;
}
if(c==2)
return true;
else
return false;
}

{
int rev = reverse(n);
int sq_of_n = n*n;
int sq_of_rev = rev*rev;
if(sq_of_n == reverse(sq_of_rev))
return true;
else
return false;
}

int reverse(int n)
{
int rev=0;
while(n!=0)
{
rev = rev*10+n%10;
n/=10;
}
return rev;
}

public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter value of m and n");
System.out.print("m = ");
int m = in.nextInt();
System.out.print("n = ");
int n = in.nextInt();

if(m>=0 && n>0 && m<n)
{
int freq=0;
for(int i=m; i<=n; i++)
{
{
freq++;
System.out.print(i + " ");
}
}
if(freq==0)
System.out.print("NIL");
System.out.println("\nFREQUENCY OF PRIME-ADAM INTEGERS IS: " +freq);
}
else
{
System.out.println("INVALID INPUT");
}
}
}```