In short, we need a*b^r+1 to be prime, and to have b as a primitive root.
| a | b | r | period (roughly) | 
|---|---|---|---|
| 222 | 28-1 | 1 | 215.8 | 
| 238 | 28-1 | 2 | 223.9 | 
| 254 | 28-1 | 4 | 240 | 
| 166 | 28-1 | 8 | 271.3 | 
| 106 | 28-1 | 16 | 2134.6 | 
| 65518 | 216-1 | 1 | 232 | 
| 65474 | 216-1 | 2 | 248 | 
| 65398 | 216-1 | 4 | 280 | 
| 65486 | 216-1 | 8 | 2144 | 
| 65234 | 216-1 | 16 | 2272 | 
| 65518 | 216-1 | 32 | 2528 | 
| 62826 | 216-1 | 64 | 21039.9 | 
| 62378 | 216-1 | 128 | 22063.9 | 
| 55962 | 216-1 | 256 | 24111.8 | 
| 4294967274 | 232-1 | 1 | 264 | 
| 4294966926 | 232-1 | 2 | 296 | 
| 4294967030 | 232-1 | 4 | 2160 | 
| 4294967054 | 232-1 | 8 | 2288 | 
| 4294966302 | 232-1 | 16 | 2544 | 
| 4294965894 | 232-1 | 32 | 21056 | 
| 4294966718 | 232-1 | 64 | 22080 | 
| 4294961686 | 232-1 | 128 | 24128 | 
| 4294944438 | 232-1 | 256 | 28224 | 
for something different, here's a Python generator.
def cmwc_r1(x=0,c=0,a=65518,b=2**16-1):
while True:
t=a*x+c
c=t/b
x=(b-1)-(t%b)
yield x
rng=cmwc_r1(x=123,c=456)
for n in rng:
print '%5d' % (n)
No comments:
Post a Comment