Question

Check whether a number is a Prime Palindrome number using recursion.

A prime palindrome integer is a positive integer (without leading zeroes) which is prime as well as a palindrome.

```				```
ENTER THE NUMBER
101
101 IS A PRIME PALINDROME NUMBER
```
```

Code

```				```
import java.util.Scanner;
{
long num=0;
public void accept()
{
Scanner sc=new Scanner(System.in);
System.out.println("ENTER THE NUMBER");
num=sc.nextLong();
}

public long FindReverse(long num,long reverse)
{
if(num==0)
{
return reverse;
}
else
{
reverse=reverse*10+num%10;
return FindReverse(num/10,reverse);
}
}

public  boolean checkPrime(long n,long i)
{
if(n< 2)
{
return false;
}
/*Check if i is greater than n/2 because if any number is divisible by another number till another number is less than or equal to num/2*/
else if(i>(n/2))
{
return true;
}

else if(n%i==0)
{
return false;
}
else
{
return  checkPrime(n,(i+1));
}
}

public void display()
{

if(checkPrime(num,2)==true && num==FindReverse(num,0))
{
System.out.println(num+" IS A PRIME PALINDROME NUMBER");
}
else
{
System.out.println(num+" IS NOT A PRIME PALINDROME NUMBER");
}

}

public static void main(String args[])
{
ob1.accept();
ob1.display();
}

}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50