Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- const int N=1e6;
- int ara[1000010];
- void sieve()
- {
- ara[0]=1;
- ara[1]=1;
- int i,j,sz=sqrt(N);
- for(i=2; i<=sz; i++)
- {
- if(ara[i]==0)
- {
- for(j=i*2; j<=N; j+=i)
- {
- ara[j]=1;
- }
- }
- }
- }
- void output()
- {
- int i;
- for(i=0; i<=1000; i++)
- {
- if(ara[i]==0)
- printf("%d\n",i);
- }
- }
- int main()
- {
- sieve();
- output();
- }
Add Comment
Please, Sign In to add comment