Linear Congruential Generators
Posted: Sat Apr 11, 2009 5:02 pm
Code: Select all
;The period of a general Linear Congruential Generator
;is at most m, and for some choices of a much less than
;that. The Linear Congruential Generator will have a full
;period if and only if:
;1. c and m are relatively prime
;2. a-1 is divisible by all prime factors of m
;3. a-1 is a multiple of 4 if m is a multiple of 4
m.l = 88 ;the modulus
a.l = 45 ;the multiplier
c.l = 47 ;the increment
x.l = 22 ;the seed or start value
For i = 1 To m
Debug x
x = (a*x+c) % m
Next