Wednesday , 28 October 2020
Latest Posts
Home » Class 12 » [Question 1] ISC 2020 Computer Practical Paper Solved – Prime Adam Number

# [Question 1] ISC 2020 Computer Practical Paper Solved – Prime Adam Number

#### Question:

A Prime-Adam integer is a positive integer (without leading zeros) which is a prirne 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.
Exarnple: If n=13 and reverse of ‘n’ =31, then,
(13)2  = 169
(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:

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.

#### Programming Code:

```/**
* The class ISC2020_Q1 inputs a lower and an upper range
* and prints all the Prime-Adam numbers within that range
* @author : www.guideforschool.com
* @Program Type : BlueJ Program - Java
* @Question Year : ISC Practical 2020 Question 1
*/
import java.util.*;
class ISC2020_Q1 //the main class
{
boolean isPrime(int n) //to check for prime number
{
int c = 0;
for(int i=1; i<=n; i++)
{
if(n%i == 0)
{
c++;
}
}
if(c == 2)
return true;
else
return false;
}

int reverseNum(int n) //to reverse a number
{
int r = 0, d = 0;
while(n > 0)
{
d = n%10;
r = r*10 + d;
n = n/10;
}
return r;
}

{
int rev = reverseNum(n);
int sqn = n*n;
int sqr = rev * rev; //square of reverse
int rsqn = reverseNum(sqn); //reverse of square
if(rsqn == sqr)
return true;
else
return false;
}

public static void main(String args[]) //the main method
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the lower limit : ");
int m = sc.nextInt();
System.out.print("Enter the upper limit : ");
int n = sc.nextInt();

ISC2020_Q1 ob = new ISC2020_Q1();

if(m<1 || n<1 || m>n) //checking for invalid input
{
System.out.println("INVALID INPUT");
}
else
{
int c = 0;
for(int i=m; i<=n; i++)
{
{
c++;
System.out.print(i + "\t");
}
}
if(c == 0)
System.out.print("NIL");
System.out.println("\nFREQUENCY OF PRIME-ADAM INTEGERS IS:" + c);
}
}
}
```

#### Output:

Enter the lower limit : 100
Enter the upper limit : 200