
eratosthenes_sieve
By:
iliya785 on
May 22nd, 2012 | syntax:
Pascal | size: 0.34 KB | hits: 24 | expires: Never
var
a:array of boolean;
i,j,n,m:longint;
Begin
read(n,m);
SetLength(a,m+1);
for i:=2 to m do
a[i]:=true;
for i:=2 to trunc(sqrt(m)) do
if a[i] then
begin
j:=sqr(i);
while (j<=m) do
begin
a[j]:=false;
inc(j,i);
end;
end;
end.