The VAX MTH$RANDOM Generator in Python
So I needed the ole’ VAX MTH$RANDOM
for a puzzle. I like python. Here’s what I came up with after reading some gsl docs:
def vax_rand(seed):
a = 69069
c = 1
m = 2**32
while True:
seed = divmod(a * seed + c, m)[1]
yield seed
To use it (with a seed of 6), do this: v = vax_rand(6)
and to get a number out of it, you could do print v.next()
.