Biology, asked by kshitijcloudline, 2 months ago

Write a program to accept a number and check and display whether it is an Emirp number or not. An Emirp number is a number which is prime backwards and forwards.

For example: 13 is an Emirp number since 13 and 31 are both prime numbers.

(JAVA)​

Answers

Answered by angeljayasing200840
2

Answer:

An Emirp Number (prime spelled backwards) is a prime number that results in a different prime when its decimal digits are reversed. This definition excludes the related palindromic primes.

Examples :

Input : n = 13

Output : 13 is Emirp!

Explanation :

13 and 31 are both prime numbers.

Thus, 13 is an Emirp number.

Input : n = 27

Output : 27 is not Emirp.

Explanation:

hop this is right

please mark as brainlist

Answered by zuhasyed07
0

Answer:

Hi

Explanation:

// Java program to check if given number is

// Emirp or not.

import java.io.*;

class Emirp {

// Returns true if n is prime. Else

// false.

public static boolean isPrime(int n)

{

 // Corner case

 if (n <= 1)

  return false;

 // Check from 2 to n-1

 for (int i = 2; i < n; i++)

  if (n % i == 0)

   return false;

 return true;

}

// Function will check whether number

// is Emirp or not

public static boolean isEmirp(int n)

{

 // Check if n is prime

 if (isPrime(n) == false)

  return false;

 // Find reverse of n

 int rev = 0;

 while (n != 0) {

  int d = n % 10;

  rev = rev * 10 + d;

  n /= 10;

 }

 // If both Original and Reverse are Prime,

 // then it is an Emirp number

 return isPrime(rev);

}

// Driver Function

public static void main(String args[]) throws IOException

{

 int n = 13; // Input number

 if (isEmirp(n) == true)

  System.out.println("Yes");

 else

  System.out.println("No");

}

}

HOPE IT HELPS YOU ...

MARK ME AS A BRAINLIEST AND THANK MY ANSWERS ... PLEASE!!

Similar questions