Blum Blum Shub

Description

Code Example

Python example:

m = 11*19 #large primes should be used
xi = 9

def rng():
    global xi
    xi = (xi * xi) % m
    return xi

for i in range(12):
    print rng()

Output:

81
82
36
42
92
104
157
196
169
137
168
9

This sequence has period 12. Careful selection of M is essential for large periods.

External Links

Blum Blum Shub - Wikipedia article on Blum Blum Shub.

Next: Caves

page_revision: 3, last_edited: 1248096067|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License