Skip to content

Commit

Permalink
isPrime will work with primes close to 2^63-1 on 64-bit machines
Browse files Browse the repository at this point in the history
  • Loading branch information
mg6maciej committed Dec 20, 2014
1 parent facdd0f commit d7453d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util_prime_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ func isPrime(value int) bool {
if value%2 == 0 || value%3 == 0 {
return false
}
v64 := int64(value)
for i := int64(5); i*i <= v64; i += 6 {
if v64%i == 0 || v64%(i+2) == 0 {
uns := uint(value)
for i := uint(5); i*i <= uns; i += 6 {
if uns%i == 0 || uns%(i+2) == 0 {
return false
}
}
Expand Down

0 comments on commit d7453d1

Please sign in to comment.