Subtractive generator: Difference between revisions
Content added Content deleted
(Added Elixir) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
||
Line 1,346: | Line 1,346: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
{{trans|PL/I}} |
{{trans|PL/I}} |
||
<lang rexx>/*REXX |
<lang rexx>/*REXX program uses a subtractive generator, and creates a sequence of random numbers.*/ |
||
numeric digits 20; s.0=292929; s.1=1; billion=10**9 |
numeric digits 20; s.0=292929; s.1=1; billion=10**9 /* ◄────────┐*/ |
||
cI=55; cJ=24; cP=34; billion=1e9 /* |
cI=55; cJ=24; cP=34; billion=1e9 /*same as─►─┘*/ |
||
do i=2 to cI-1 |
do i=2 to cI-1 |
||
s.i=mod(s(i-2) - s(i-1), billion) |
s.i=mod(s(i-2) - s(i-1), billion) |
||
Line 1,364: | Line 1,364: | ||
say right(r.y, 40) |
say right(r.y, 40) |
||
end /*n*/ |
end /*n*/ |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
|||
/*────────────────────────────────────────────────────────────────────────────*/ |
|||
mod: procedure; |
mod: procedure; parse arg a,b; return ((a // b) + b) // b |
||
r: |
r: parse arg _; return r._ |
||
s: |
s: parse arg _; return s._</lang> |
||
'''output''' when using the default input: |
'''output''' when using the default input: |
||
<pre> |
<pre> |