View Code of Problem 92

#include <stdio.h>
#include <math.h>
main(){
	int a,b,x[10000],i,j=0,t,m;
	scanf("%d%d",&a,&b);
	while(a<=b){
		t = a;
		int y = 0;
		while(t > 0){
			y = y*10 +t%10;
			t = t/10;
		}
		if(y == a){
			m = (int)sqrt((double)a);
			for(i = 2; i<=m; i++){
				if(a%i==0)
					break;
			}
			if(i>m){
				x[j] = a;
				j++;
			}
		}
		a++;
	}
	for(i =1;i<=j;i++){
		if(i%5==0)
			printf("%6d\n",x[i-1]);
		else
			printf("%6d",x[i-1]);

	}
}

Double click to view unformatted code.


Back to problem 92