标签:style http color io os ar for 数据 div
5 10 11 0
2 3 5 2 3 5 7 2 3 5 7 11
代码:
#include<stdio.h> #define MAX 2000100 int f[MAX]={1,1}; void g() { int i,j; for(i=2;i*i<MAX;++i) { for(j=2;j<i;++j) if(i%j==0) break; if(j==i) { f[i]=0; for(j=i*i;j<MAX;j+=i) f[j]=1; } else f[i]=1; } } int main() { g(); int N,i; while(scanf("%d",&N),N) { printf("2"); for(i=3;i<=N;++i) if(!f[i]) printf(" %d",i); printf("\n"); } return 0; }
标签:style http color io os ar for 数据 div
原文地址:http://blog.csdn.net/qq_18062811/article/details/39432241