RosettaCodeData/Task/Linear-congruential-generator/Pascal/linear-congruential-generator.pascal

35 lines
545 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
Program LinearCongruentialGenerator(output);
2019-09-12 10:33:56 -07:00
{$mode iso}
2013-04-10 22:43:41 -07:00
var
x1, x2: int64;
2019-09-12 10:33:56 -07:00
function bsdrand: cardinal;
2013-04-10 22:43:41 -07:00
const
a = 1103515245;
c = 12345;
m = 2147483648;
begin
x1 := (a * x1 + c) mod m;
bsdrand := x1;
end;
2019-09-12 10:33:56 -07:00
function msrand: cardinal;
2013-04-10 22:43:41 -07:00
const
a = 214013;
c = 2531011;
m = 2147483648;
begin
x2 := (a * x2 + c) mod m;
msrand := x2 div 65536;
end;
var
2019-09-12 10:33:56 -07:00
i: cardinal;
2013-04-10 22:43:41 -07:00
begin
writeln(' BSD MS');
x1 := 0;
x2 := 0;
for i := 1 to 10 do
writeln(bsdrand:12, msrand:12);
end.