- 分享
 素数判断
- @ 2023-12-31 14:54:30
 
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long x)
{
	if(x==2) return true;
	if(x<2 || x%2==0)  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<<"yes";
	else cout<<"no";
	return 0;
}
        0 comments
  
  No comments so far...