/*
Write a program to create following methods:
i. boolean palindrome(int n), which returns true if n is a palindrome otherwise returns false.
ii. boolean prime(int n), which returns true if n is prime otherwise returns false.
iii. void display() to display all three digits pal-prime numbers. Pal-prime numbers are
those numbers which are both palindrome as well as prime.
*/
import java.util.*;
class pal_prime
{
boolean isPalindrome(int n)
{
int r,k=n,s=0;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(s==k)
return true;
else
return false;
}
boolean isPrime(int n)
{
int i,c=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
if(c==2)
return true;
else
return false;
}
void display()
{
System.out.println("All three digits Pal-Prime number are:");
for(int i=100;i<=999;i++)
{
if(isPalindrome(i)==true && isPrime(i)==true)
System.out.println(i);
}
}
public static void main(String[]args)
{
pal_prime obj=new pal_prime();
obj.display();
}
}