View Code of Problem 92

#include<bits/stdc++.h>
using namespace std;

int main() {

	int m,n;
	cin>>m>>n;
	int num=0;
	for(int i=m;i<=n;i++){
		stringstream ss;
		string s;
		ss<<i;
		ss>>s;
		string rs=s;
		reverse(s.begin(),s.end());
		if(s==rs){
			int flag=0;
			for(int j=2;j*j<=i;j++){
				if(i%j==0){
					flag=1;
					break;
				}
			}
			if(flag==0){
				num++;
				printf("%6d",i);
				if(num==5){
					num=0;
					cout<<endl;
				}
				
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 92