1
0
mirror of https://github.com/golang/go synced 2024-11-23 14:50:07 -07:00

math: Added parity check to ProbablyPrime

Fixes #9269

Change-Id: I25751632e95978537b656aedfa5c35ab2273089b
Reviewed-on: https://go-review.googlesource.com/1380
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Alberto Donizetti 2014-12-11 19:09:39 +01:00 committed by Robert Griesemer
parent da43976c8b
commit 5de497bc6f

View File

@ -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}