Jump to content

Subtractive generator: Difference between revisions

Added 11l
m (→‎{{header|REXX}}: optimized the code, added/changed whitesdpace.)
(Added 11l)
Line 36:
Implement a subtractive generator that replicates the sequences from ''xpat2''.
<br><br>
 
=={{header|11l}}==
{{trans|Python: With explanation}}
 
<lang 11l>Deque[Int] s
V seed = 292929
 
s.append(seed)
s.append(1)
 
L(n) 2..54
s.append((s[n - 2] - s[n - 1]) % 10 ^ 9)
 
Deque[Int] r
L(n) 55
V i = (34 * (n + 1)) % 55
r.append(s[i])
 
F py_mod(a, b)
R ((a % b) + b) % b
 
F getnextr()
:r.append(py_mod((:r[0] - :r[31]), 10 ^ 9))
:r.pop_left()
R :r[54]
 
L 0 .< 219 - 54
getnextr()
 
L 5
print(‘result = ’getnextr())</lang>
 
{{out}}
<pre>
result = 467478574
result = 512932792
result = 539453717
result = 20349702
result = 615542081
</pre>
 
=={{header|Ada}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.