Cod sursa(job #884950)
Utilizator | Data | 21 februarie 2013 15:12:22 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include<stdio.h>
int n,x,y,c,z,v[2000002];
int main()
{
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
scanf("%d",&n);
x=2;
z=0;
while(x<=n)
{
if(v[x]==0)
{
z++;
for(y=2*x;y<=n;y=y+x)
{
v[y]=1;
}
}
x=x+1;
}
printf("%d",z);
fclose(stdin);
fclose(stdout);
return 0;
}