First check the number is prime or not , if prime then check the palindrome or not.
Example : 101, 131, 151, 181.
import java.util.*;
class primepalindrome
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int c=0,n,rev=0,s=0,r;
System.out.println("Enter the no");
n=sc.nextInt();
for(int i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
if(c==2)
rev=n;
while(rev>0)
{
r=rev%10;
s=s*10+r;
rev=rev/10;
}
if(n==s)
System.out.println("Prime Palindrome");
else
System.out.println("Not Prime Palindrome");
}
}
Example : 101, 131, 151, 181.
import java.util.*;
class primepalindrome
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int c=0,n,rev=0,s=0,r;
System.out.println("Enter the no");
n=sc.nextInt();
for(int i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
if(c==2)
rev=n;
while(rev>0)
{
r=rev%10;
s=s*10+r;
rev=rev/10;
}
if(n==s)
System.out.println("Prime Palindrome");
else
System.out.println("Not Prime Palindrome");
}
}