- hzoi044 的博客
判断素数的个数
- @ 2024-7-25 17:33:13
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,t=0,c=0;
cin>>a>>b;
if(a>b)
swap(a,b);
for(int i=a;i<=b;i++)
{
if(i==1)
continue;
c=0;
for(int j=2;j<=sqrt(i);j++)
{
if(i%j==0)
{
c=1;
break;
}
}
if(c==0)
t++;
}
cout<<t;
return 0;
}