Javatpoint Logo
Javatpoint Logo

PalPrime Number Java

The PalPrime number is a special positive number which is also known as the Palindromic Prime number. A number is said to be a palindromic prime if the number is a palindrome as well as a prime. So, a number having properties of both the palindrome and prime number is referred to as the PalPrime number or Palindromic Prime number.

A palindrome number is a number that remains the same after reversing each digit of that number.

A prime number is a number that is divisible by only one or itself.

So, a number that remains the same after reversing each digit of the number and that number is divisible by itself, or one is referred to as the PalPrime number.

Let's take some examples of PalPrime numbers.

  1. 313 is a PalPrime number because after reversing that number, the number retains its original value, and the number is also divisible by only one or itself.
  2. 252 is not a PalPrime number because after reversing the number, the number retains its original value, but it is not only divisible by one or itself.
  3. 353 is also a prime number because it follows the properties of palindrome and prime number both.
PalPrime Number Java

Steps to check PalPrime number

In order to check whether the number is PalPrime or not, we have to follow the following steps:

  1. Get a number from the user to check whether it is PalPrime or not.
  2. We store that number in a temporary variable so that the original value remains the same.
  3. We use the "for loop" to check whether the number is prime or not.
  4. We also check whether the number is palindrome or not.
  5. If the number is both Prime and Palindrome, print "number is a PalPrime number.".
  6. If not, then print "number is not a PalPrime number.".

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

PalPrimeNumber.java

Output:

PalPrime Number Java

FindAllPalPrimeNumbers.java

Output:

PalPrime Number Java
Next TopicTwin Prime Numbers





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA