Jump to content

Linear congruential generator: Difference between revisions

Line 1,938:
 
=={{header|Pascal}}==
{{incorrect|Pascal|Incorrect output. [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])}}
<lang pascal>Program LinearCongruentialGenerator(output);
{$mode iso}
 
var
x1, x2: int64;
 
function bsdrand: longintcardinal;
const
a = 1103515245;
Line 1,953 ⟶ 1,952:
bsdrand := x1;
end;
 
function msrand: longintcardinal;
const
a = 214013;
Line 1,963 ⟶ 1,962:
msrand := x2 div 65536;
end;
 
var
i: longintcardinal;
begin
writeln(' BSD MS');
Line 1,972 ⟶ 1,971:
for i := 1 to 10 do
writeln(bsdrand:12, msrand:12);
end.</lang>
</lang>
Output:
<pre> BSD MS
12345 7584 38
11246521451406932606 32777719
1499545833 654583775 306721238
15584060491449466924 31446 2437
696007321229283573 13069 8855
1109335178 56579025 1734311797
13127058651051550459 25108365
1293799192 811881729 526432285
1301653753 794471793 21298 10450
1318262577 551188310 27689 306129</pre>
 
=={{header|Perl}}==
61

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.