Cod sursa(job #2175228)
Utilizator | Data | 16 martie 2018 16:04:55 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <stdio.h>
int n, nr;
char prim[2000005];
int main()
{
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &n);
for (int i = 2; i <= n; ++i)
prim[i] = 1;
for (int i = 2; i <= n; ++i)
if (prim[i])
{
++nr;
for (unsigned long long int j = i+i; j <= n; j += i)
prim[j] = 0;
}
printf("%d\n", nr);
return 0;
}