Cod sursa(job #845497)
Utilizator | Data | 30 decembrie 2012 22:30:35 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
program ciurul_Eratostene;
var f:text;
n,k,i,c:longint;
a:array [2..2000000] of byte;
begin
assign(f,'ciur.in');
reset(f);
readln(f,n);
close(f);
for i:=2 to n do
begin
if a[i]=0 then
begin
inc(k);
c:=2*i;
while c<=n do begin a[c]:=1; c:=c+i; end;
end;
end;
assign(f,'ciur.out');
rewrite(f);
writeln(f,k);
close(f);
end.