Cod sursa(job #426478)
Utilizator | Nociv Hasis ivanhoe | Data | 26 martie 2010 23:44:13 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
var
n,d,i,c:longint;
ok:boolean;
f,g:text;
begin
assign(f,'ciur.in');
reset(f);
readln(f,n);
close(f);
i:=2;
while (i<=n) do
begin
ok:=true;
d:=2;
while (d<=i/d) and ok do
if i mod d=0
then
begin
ok:=false;
break
end
else
if d=2
then
d:=3
else
d:=d+2;
if ok
then
c:=c+1;
i:=i+1;
end;
assign(g,'ciur.out');
rewrite(g);
writeln(g,c);
close(g);
end.