Cod sursa(job #625261)
| Utilizator | Data | 24 octombrie 2011 09:25:44 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 20 |
| Compilator | fpc | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
program ciur_erathosthenes;
var n,i,j,t,h:longint;
d,o:text;
begin
assign(d,'ciur.in');
assign(o,'ciur.out');
reset(d);rewrite(o);
read(d,n);
t:=n-1;
for i:=2 to (n div 2) do
begin
j:=i*2;
while j<=n do
begin
t:=t-1;
for h:=i+1 to (j div 2) do
if j mod h=0 then begin
t:=t+1;
break;
end;
j:=j+i;
end;
end;
write(o,t);
close(d);close(o);
end.