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