Cod sursa(job #386430)
Utilizator | Data | 24 ianuarie 2010 20:12:54 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<fstream.h>
long i, j, n, c, nr, d, ok;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
fin>>n;
for(i=2;i<=n;i++)
{
ok = 1;
d = 2;
while((d<=i/2)&&(ok==1))
{
if(i%d==0)
ok = 0;
d++;
}
if(ok == 1)
c++;
}
fout<<c;
fout.close();
return 0;
}