Sattolo cycle: Difference between revisions

Line 948:
uses math;
var
a:Array of cardinal = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];
i,j:integer;
t:cardinal;
begin
randomize;
a:=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];
i := length(a);
while i > 1 do
while i > 1 do // do not touch this, otherwise it becomes durstenfeld or worse
begin
dec(i);
j :=randomrange(0,i); //Low actually low(a) is always 0 for dynarrays.
t:=a[i];a[i]:=a[j];a[j]:=t;
write(a[i]:4);
end;
writeln;
end.</syntaxhighlight>
<pre>
61

edits