#include<iostream>
#include<math.h>
using namespace std;
int is_prime(int p){
int j,k=0;
for(j=2;j<=p;j++){
if(p%j!=0)k++;
break;
}
if(k==0)return 0;
else return 1;
}
int main(){
int m,n,i,f;
cin>>m>>n;
if(m==0&&n==0)cout<<"end"<<endl;
if(m>n){
int temp=n;n=m;m=temp;
}
for(i=m;i<=n;i++){
int p=i*i+i+41;
if(is_prime(p)==0){
f=0;
break;
}
if(f=0)cout<<"Sorry"<<endl;
else cout<<"OK"<<endl;}
system("pause");
return 0;
}
原文地址:https://www.cnblogs.com/huoyuying/p/9735688.html
时间: 2024-09-30 04:55:47