Cod sursa(job #153307)
Utilizator | Data | 10 martie 2008 13:27:13 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <stdio.h>
int N, cnt;
int prim(int X)
{
int i;
for (i = 2; i * i <= X; ++i)
if (X % i == 0)
return 0;
return 1;
}
int main(void)
{
int i;
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &N);
for (i = 2; i <= N; ++i)
if (prim(i))
++cnt;
printf("%d\n", cnt);
return 0;
}