#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 r=0,temp=i; while(temp){ r=r*10+temp%10; temp/=10; } if(i==r){ int flag = 0; for(int j=2;j<sqrt(i);j++){ if(i%j==0){ flag=0; break; } else if(flag==0) flag=1; } if(flag==1){ cout<<setw(6)<<i; t++; if(t%5==0) cout<<endl; } } } cout<<endl; return 0; } |
Double click to view unformatted code.