Prime Palindrome Number is a number which is a Prime Number as well as Palindrome Number.
Prime Number is a number which is only divisible by 1 and the number itself i.e., it has no factors other than 1 and itself.
Palindrome Number is a number which is equal to reverse of itself.
Example 1: 131 if reversed is also 131. Also it is a Prime Number. Hence it is a Prime Palindrome Number.
Example 2: 121 if reversed is also 121. Here it is a Palindrome Number but not a Prime Number since it is divisible by 11 also. Hence it is not a Prime Palindrome Number.
Example 3: 113 if reversed is 311. Here it is not a Palindrome Number but a Prime Number. Hence it is not a Prime Palindrome Number
Java
import java.util.*;
public class PrimePalindromeNumber
{
public static void main(String args[])
{
int n=0,r=0,nCopy=0,rev=0,flag=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
n=sc.nextInt();
nCopy=n;
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
flag++;
}
}
if(flag==2)
{
while(n>0)
{
r=n%10;
rev=(rev*10)+r;
n=n/10;
}
if(rev==nCopy)
{
System.out.println(nCopy+" is a Prime Palindrome Number");
flag=0;
}
}
if(flag!=0)
{
System.out.println(nCopy+" is not a Prime Palindrome Number");
}
}
}
Java