2 From http://www.4dsolutions.net/cgi-bin/py2html.cgi?script=/ocn/python/primes.py
9 Randomly generate a probable prime with a given
13 candidate = random.getrandbits(bits)
19 prob=pptest(candidate)
26 Simple implementation of Miller-Rabin test for
27 determining probable primehood.
29 bases = [random.randrange(2,50000) for x in range(90)]
31 # if any of the primes is a factor, we're done
41 # turning (n-1) into (2**s) * m
43 while not m&1: # while m is even
49 isprob = algP(m,s,b,n)
52 if isprob: return (1-(1./(4**tests)))
57 based on Algorithm P in Donald Knuth's 'Art of
58 Computer Programming' v.2 pg. 395
63 if (y==1 and j==0) or (y==n-1):