#include <iostream.h>
#include <conio.h>
void main(){
int flag,rev;
cout<< "\n The palindrome prime numbers between 100 to 500 are :\n";
for(int n = 100 ; n<=500 ; n ++ )
{
flag = 0;
/* Check Prime number for each n */
for(int j = 2; j < = n-1 ; j++)
{
if(n%j == 0)
{
flag = 1;
break;
}
}
rev = 0;
//reverse the number and check palindrome
if(flag == 0)
{
for(int k = n; k >=1 ; k = k/10)
{
rev = rev*10 + k%10;
}
if(rev == n)
cout<< n << " " ;
}
}
getch();
}
No comments:
Post a Comment