Cod sursa(job #515433)
Utilizator | Data | 21 decembrie 2010 15:01:05 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <stdio.h>
#define N 2000000
int main(void) {
long n, a[N], i, j, cnt = 0;
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%ld", &n);
for(i = 2; i <= n; ++i)
a[i] = 1;
for(i = 2; i <= n; ++i)
if(a[i]) {
++cnt;
for(j = i + i; j < n; j += i)
a[j] = 0;
}
printf("%ld", cnt);
return 0;
}