- 分享
素数判断
- 2023-12-31 14:53:11 @
#include <bits/stdc++.h> using namespace std; bool isPrime(long long x) { if(x2) return true; if(x<2 || x%20) return false; for(int i=3;i<=sqrt(x);i+=2) { if(x%i==0) { return false; } } return true; } int main() { long long a=0; cin>>a; if(isPrime(a)==true) cout<<"质数"; else cout<<"不是质数"; return 0; }
0 comments
No comments so far...