View Code of Problem 92

#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    int m,n,t=0;
    cin>>m>>n;
    for(int i=m;i<=n;i++){
        int temp=i,r=0;
        while(temp){
            r=r*10+temp%10;
            temp=temp/10;
        }
        if(r==i){
            int flag=1;
            for(int j=2;j<=sqrt(i);j++){
                if(i%j==0){
                    flag=0;
                    break;
                }
            }
            if(flag==1){
                
                if(t%5==0&&t!=0){
                    cout<<endl;
                }
                t++;
                cout<<setw(6)<<i;
                    }
        }
    }
    cout<<endl;
    return 0;
}












Double click to view unformatted code.


Back to problem 92