Javatpoint Logo
Javatpoint Logo

Twisted Prime Number Java

The Twisted Prime number is a special prime number which is also known as the Emirp number. A number is a twisted prime number if the reverse of the number is also a prime number.

Let's take some examples of twisted prime numbers and non-twisted prime numbers.

  1. 79 is a twisted prime number because after reversing it, we get 97, i.e., a prime number also.
  2. 43 is not a twisted prime number because after reversing it, we get 34, i.e., not a prime number.
  3. 37 is also a twisted prime number because after reversing it, we get 73, i.e., a prime number also.
Twisted Prime Number Java

Steps to check twisted prime number

These are the following steps that we can use to implement the logic of twisted prime number:

  1. Take a number from the user to check.
  2. After that, we check whether the number is prime or not because the twisted prime number is a prime number in itself.
  3. If the number is a prime number, we reverse each digit of the number to get a new number.
  4. If the newly generated number is prime, we print "number is a twisted prime number". Otherwise, print "number is not a twisted prime number".

Let's implement the code to check whether the number is a twisted prime number or not.

TwistedPrimeNumbers.java

Output:

Twisted Prime Number Java

FindAllTwistedPrimeNumbers.java

Output:

Twisted Prime Number Java

Output:


Next TopicUgly number Java




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA