关于判断质数

#include<bits/stdc++.h>

using namespace std;

int main(){
int n;
cin>>n;
int flag=1;
for(int i=2;i*i<=n;i++){
if(n%i==0) flag=0;
}
if(flag==1) cout<<n<<" is a prime";
else cout<<n<<" isn't a prime";
}

posted @ 2021-09-28 21:12  Altwilio  阅读(26)  评论(0编辑  收藏  举报