Linear congruential generator: Difference between revisions
Content added Content deleted
(Added Fōrmulæ solution) |
(Added Quackery.) |
||
Line 2,744: | Line 2,744: | ||
return seed >> 16 |
return seed >> 16 |
||
return rand</lang> |
return rand</lang> |
||
=={{header|Quackery}}== |
|||
<lang Quackery> [ number$ |
|||
10 over size - |
|||
space swap of |
|||
swap join echo$ ] is echonum ( n --> ) |
|||
[ stack 0 ] is BSD-seed ( --> n ) |
|||
[ BSD-seed take |
|||
1103515245 * |
|||
12345 + |
|||
hex 7FFFFFFF & |
|||
dup BSD-seed put ] is BSD-rand ( --> n ) |
|||
[ stack 0 ] is MCR-seed ( --> n ) |
|||
[ MCR-seed take |
|||
214013 * |
|||
2531011 + |
|||
hex 7FFFFFFF & |
|||
dup MCR-seed put |
|||
16 >> ] is MCR-rand ( --> n ) |
|||
say " BSD-rand MCR-rand" cr |
|||
10 times |
|||
[ BSD-rand echonum |
|||
MCR-rand echonum cr ]</lang> |
|||
{{out}} |
|||
<pre> BSD-rand MCR-rand |
|||
12345 38 |
|||
1406932606 7719 |
|||
654583775 21238 |
|||
1449466924 2437 |
|||
229283573 8855 |
|||
1109335178 11797 |
|||
1051550459 8365 |
|||
1293799192 32285 |
|||
794471793 10450 |
|||
551188310 30612 |
|||
</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |