A **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, 13^{2} = 169, and 31^{2} = 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:

The Prime-Adam integers are:

11, 13, 31

Frequency of Prime-Adam integers is: 3

**Example 2**:

INPUT:

m = 100

n = 200

OUTPUT:

The Prime-Adam integers are:

101, 103, 113

Frequency of Prime-Adam integers is: 3

**Example 3**:

INPUT:

m = 50

n = 70

OUTPUT:

The Prime-Adam integers are:

NIL

Frequency of Prime-Adam integers is: 0

**Example 4**:

INPUT:

m = 700

n = 450

OUTPUT:

Invalid Input.

```
import java.io.*;
class PrimeAdam{
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("m = ");
int m = Integer.parseInt(br.readLine());
System.out.print("n = ");
int n = Integer.parseInt(br.readLine());
if(m >= n){
System.out.println("Invalid input.");
return;
}
int count = 0;
System.out.println("The Prime-Adam integers are:");
for(int i = m; i <= n; i++){
if(isPrime(i)){
int rev = reverse(i);
int s1 = i * i;
int s2 = rev * rev;
if(reverse(s1) == s2){
if(count == 0)
System.out.print(i);
else
System.out.print(", " + i);
count++;
}
}
}
if(count == 0)
System.out.println("NIL");
else
System.out.println();
System.out.println("Frequency of Prime-Adam integers is: " + count);
}
public static boolean isPrime(int n){
int f = 0;
for(int i = 1; i <= n; i++){
if(n % i == 0)
f++;
}
return f == 2;
}
public static int reverse(int n){
int rev = 0;
for(int i = n; i > 0; i /= 10)
rev = rev * 10 + i % 10;
return rev;
}
}
```

Sir, i want algorithms of all practical papers from 2020-2012.

OK. I will try to post them soon.

Sir,how to write the above program of Prime Adam number using Python???

Sir,a program is given which states that:

WAP in Java to accept a hexadecimal number and convert it to its decimal equivalent using recursive function .

Eg:

Hexadecimal Number:A

Decimal Equivalent:10

Sir,in the above program can I use

if(m<0||n<0)

for checking whether 2 numbers are entered positive or not

Yes!