Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
365 B
3
Indexable
Never
#include <stdio.h>

#define N 1000

int main(){

    int i, j, a[n];
    a[0] = 0;
    a[1] = 0;
    for(i = 2; i < N; i++)
    {
        a[i] = 1;
    }
    for(i = 2; i < N; i++)
    {
        if(a[i])
        {
            for(j = i; j < N/i; j++) a[i*j] = 0;
        }
    }
    for(i = 2; i < N; i++)
        if(a[i]) printf("%4d ", i);
    printf("\n")
    
}
Leave a Comment