2024-11-06 04:24:19
2024-11-06 04:49:59
#include <iostream>
using namespace std;
int main()
{
int N,i,j,num=1;
bool temp=true;
cin>>N;
cout<<2<<" ";//2是素数 所以num从1开始
for(i=3;i<=N;i++)
{
temp=true;
for(j=2;j*j<=i;j++)
{
if(i%j==0)
{
temp=false;
break;
}
}
if(temp)
{
num++;
cout<<i<<" ";
}
}
cout<<endl;
}
2024-11-06 05:31:23