View Code of Problem 92

#include <iostream>
using namespace std;

int main() {
	int m,n,a[1000],p=0;
	cin >>m>>n;
	for(int i=m;i<=n;i++){
		int x=0,j=i;
		while(j){
			x=x*10+j%10;
			j/=10;
		}
		if(i==x){
			int l=2,flag=0;
			while(l<i){
				if(i%l==0)
					flag=1;
				l++;
			}
			if(flag ==0){
				a[p++]=i;
			}
		}
	}
	for(int i=0;i<p;i++){
		printf("%6d",a[i]);
		if((i+1)%5==0) printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 92