Студэнt
//Алгоритм: Решето Эратосфена const n=1000; var i, j, count: integer; b: array[1..n] of boolean; begin count:=0; for i:=1 to n do b[i]:=false; for i:=2 to n do if not b[i] then begin inc(count); //write (i, '; '); j:=1; while (i*j<=n) do begin b[i*j]:=true; inc(j); end; end; write (count); end.
Answers & Comments
const n=1000;
var
i, j, count: integer;
b: array[1..n] of boolean;
begin
count:=0;
for i:=1 to n do b[i]:=false;
for i:=2 to n do
if not b[i] then
begin
inc(count);
//write (i, '; ');
j:=1;
while (i*j<=n) do
begin
b[i*j]:=true;
inc(j);
end;
end;
write (count);
end.