Subtractive generator: Difference between revisions

m
→‎{{header|REXX}}: elided a blank line, aligned some statements, changed some comments.
m (Formatting.)
m (→‎{{header|REXX}}: elided a blank line, aligned some statements, changed some comments.)
Line 1,742:
Some optimization was done so that the first two   '''do'''   loops executed faster.
<lang rexx>/*REXX program uses a subtractive generator, and creates a sequence of random numbers. */
s.0= 292929; s.1= 1; s.1= 1; billion= 1e9 /* ◄────────┐ */ billion= 1e9
numeric digits 20
numeric digits 20; billion= 10**9 /*same as─►─┘ */
cI= 55; do i=2 for cI-2; s.i= mod( s(i-2) - s(i-1), billion)
end /*i*/
 
s.i= mod( s(i-2) - s(i-1), billion)
end /*i*/
Cp= 34
do j=0 for cI; r.j= s( mod( cP * (j+1), cI))
end r.j= s( mod( cP /* (j+1), cI))*/
end /*j*/
m= 219; Cj= 24
do k=cI to m; _= k // cI
r._= mod( r( mod(k-cI, cI)) - r( mod(k-cJ, cI) ), billion)
end /*m*/
t= 235
do n=m+1 to t; _= n // cI
r._= mod( r( mod(n-cI, cI)) - r( mod(n-cJ, cI) ), billion)
say right(r._, 40)
end /*n*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
mod: procedure; parse arg a,b; return ( (a // b) + b) // b
r: parse arg #; return r.#
s: parse arg #; return s.#</lang>
{{out|output|text=&nbsp; when using the default input:}}
<pre>