mirror of
https://github.com/golang/go
synced 2024-11-23 18:00:06 -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:
parent
da43976c8b
commit
5de497bc6f
@ -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 primesProduct32 = 0xC0CFD797 // Π {p ∈ primes, 2 < p <= 29}
|
||||||
const primesProduct64 = 0xE221F97C30E94E1D // Π {p ∈ primes, 2 < p <= 53}
|
const primesProduct64 = 0xE221F97C30E94E1D // Π {p ∈ primes, 2 < p <= 53}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user