Pseudo-random numbers/Middle-square method: Difference between revisions
Pseudo-random numbers/Middle-square method (view source)
Revision as of 00:32, 19 October 2022
, 1 year agoAdded Quackery.
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(Added Quackery.) |
||
Line 717:
524817
432883</pre>
=={{header|Quackery}}==
As specified in task pseudo-code.
<syntaxhighlight lang="Quackery"> [ dip [ split nip ]
split drop ] is mid ( [ n n --> [ )
[ stack 675248 ] is seed ( --> n )
[ seed take
dup * number$
[ dup size 12 != while
char 0 join
again ]
3 6 mid $->n drop
dup seed put ] is rand ( --> n )
5 times [ rand echo sp ]</syntaxhighlight>
Divide and modulo.
<syntaxhighlight lang="Quackery"> [ stack 675248 ] is seed ( --> s )
[ seed take
dup * 1000 /
1000000 mod
dup seed put ] is rand ( --> n )
5 times [ rand echo sp ]</syntaxhighlight>
{{out}} For both versions.
<pre>959861 333139 981593 524817 432883</pre>
=={{header|Raku}}==
|