Question

# Program to Check whether a given number is a Emirp number.(An Emirp Number (prime spelt backwards) is a prime number that results in a different prime when its digits are reversed.)

```				```
Example 1:
Enter a number:
113
113 is an Emirp number
Here 113 is a prime number
Reverse of 113 is 311 which is also prime.
As both the given number and reverse of number is prime therefore,13 is an emirp number.

Example 2:
Enter a number:
19
19 is not an Emirp number
Here 19 is a prime number
Reverse of 19 is 91 which is mot a prime as 91 is divisible by 13.
As only given number is prime but not reverse of number therefore,19 is not an emirp number.
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;

public class emirpNumber
{
//Function isPrime(int n) checks if number is Prime
//If it is true then return true elese return false
public static boolean isPrime(int n)
{
int i=0;
if(n>1)
{
for(i=2;i< n;i++)
{
if(n%i==0)
{
return false;

}
}
return true;
}
else
{
return false;
}

}
//Function reverse(int n) returns reverse of a number
public static int reverse(int n)
{
int temp=0,rev=0,rem=0;
temp=n;
while(temp>0)
{
rem=temp%10;
rev=rev*10+rem;
temp=temp/10;
}
return rev;
}
public static void main()
{
int reverseNum=0,num=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number:");
num=sc.nextInt();
reverseNum=reverse(num);
if(isPrime(num)==true && isPrime(reverseNum)==true)
{
System.out.println(num+" is an Emirp number");
}
else
{
System.out.println(num+" is not an Emirp number");

}
}
}

```
```

## Coding Store

Sale ### Mastering String

50
Sale 150
Sale 200
Sale ### Mastering Recursion

50
Sale ### Mastering Numbers

50
Sale ### Mastering Matrix

50
Sale ### Mastering Array

50
Sale ### ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)

50
Sale 50