Ensure that random-prime result has the right size
As noted by Slava, choosing the next prime following a random number with a specified number of bits may give a number one more bit long.db4
parent
b7c50e6159
commit
e5897d52b2
|
@ -56,7 +56,8 @@ PRIVATE>
|
|||
: coprime? ( a b -- ? ) gcd nip 1 = ; foldable
|
||||
|
||||
: random-prime ( numbits -- p )
|
||||
random-bits* next-prime ;
|
||||
[ ] [ 2^ ] [ random-bits* next-prime ] tri
|
||||
2dup < [ 2drop random-prime ] [ 2nip ] if ;
|
||||
|
||||
: estimated-primes ( m -- n )
|
||||
dup log / ; foldable
|
||||
|
|
Loading…
Reference in New Issue