Linear congruential generator: Difference between revisions
Content added Content deleted
Line 1,938: | Line 1,938: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
{{incorrect|Pascal|Incorrect output. [[User:Petelomax|Pete Lomax]] ([[User talk:Petelomax|talk]])}} |
|||
<lang pascal>Program LinearCongruentialGenerator(output); |
<lang pascal>Program LinearCongruentialGenerator(output); |
||
{$mode iso} |
|||
var |
var |
||
x1, x2: int64; |
x1, x2: int64; |
||
function bsdrand: |
function bsdrand: cardinal; |
||
const |
const |
||
a = 1103515245; |
a = 1103515245; |
||
Line 1,953: | Line 1,952: | ||
bsdrand := x1; |
bsdrand := x1; |
||
end; |
end; |
||
function msrand: |
function msrand: cardinal; |
||
const |
const |
||
a = 214013; |
a = 214013; |
||
Line 1,963: | Line 1,962: | ||
msrand := x2 div 65536; |
msrand := x2 div 65536; |
||
end; |
end; |
||
var |
var |
||
i: |
i: cardinal; |
||
begin |
begin |
||
writeln(' BSD MS'); |
writeln(' BSD MS'); |
||
Line 1,972: | Line 1,971: | ||
for i := 1 to 10 do |
for i := 1 to 10 do |
||
writeln(bsdrand:12, msrand:12); |
writeln(bsdrand:12, msrand:12); |
||
end. |
end. |
||
</lang> |
|||
Output: |
Output: |
||
<pre> BSD MS |
<pre> BSD MS |
||
12345 |
12345 38 |
||
1406932606 7719 |
|||
654583775 21238 |
|||
1449466924 2437 |
|||
229283573 8855 |
|||
1109335178 11797 |
|||
1051550459 8365 |
|||
1293799192 32285 |
|||
794471793 10450 |
|||
551188310 306129</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |