Commit 5de497bc authored by Alberto Donizetti's avatar Alberto Donizetti Committed by Robert Griesemer

math: Added parity check to ProbablyPrime

Fixes #9269

Change-Id: I25751632e95978537b656aedfa5c35ab2273089b
Reviewed-on: https://go-review.googlesource.com/1380Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
parent da43976c
......@@ -1404,6 +1404,10 @@ func (n nat) probablyPrime(reps int) bool {
}
}
if n[0]&1 == 0 {
return false // n is even
}
const primesProduct32 = 0xC0CFD797 // Π {p ∈ primes, 2 < p <= 29}
const primesProduct64 = 0xE221F97C30E94E1D // Π {p ∈ primes, 2 < p <= 53}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment