Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <stdlib.h>
- #define N 10000
- int main ()
- {
- int i,j=1;
- int *array;
- array = (int *) malloc(sizeof(int)*N);
- for (i=0;i<N;i++)
- {
- array[i]=i+2;
- }
- for (i=0;array[i]<sqrt(N);i++)
- {
- if (array[i]!=0)
- {
- while ((array[i]*j)<N)
- {
- array[i+j*array[i]]=0;
- j++;
- }
- }
- j=1;
- }
- for(i=0;i<N;i++)
- {
- if (array[i]!=0)
- {
- printf("%d ", array[i]);
- }
- }
- free(array);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement