Skip to content

Instantly share code, notes, and snippets.

@dynamitechetan
Created August 8, 2016 15:48
Show Gist options
  • Save dynamitechetan/6d86db782f43345227fba9f723f1c8d3 to your computer and use it in GitHub Desktop.
Save dynamitechetan/6d86db782f43345227fba9f723f1c8d3 to your computer and use it in GitHub Desktop.
This is for my college freinds: Program to find Palindromic Prime
int main() {
int x,y,n,z,rem,prime=0,pal=0,sum;
scanf("%d",&x);
scanf("%d",&y);
for(int i=x;i<=y;i++){
prime=0;
for(int j=2; j<i; j++){
if(i%j==0){
prime=1;
break;
}
}
if(prime==0){
n=i;
pal=0;
while(n!=0){
rem=n%10;
pal=pal*10+rem;
n=n/10;
}
if(pal==i){
sum=sum+i;
}
}
}
printf("%d",sum);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment