Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ version = "0.5.1"

[extras]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
IntegerMathUtils = "18e54dd8-cb9d-406c-a71d-865a43cbb235"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["DataStructures", "Test"]
test = ["DataStructures", "IntegerMathUtils", "Test"]

[compat]
DataStructures = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17"
IntegerMathUtils = "0.1"
julia = "1"
7 changes: 2 additions & 5 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Base.Iterators: repeated
import Base: iterate, eltype, IteratorSize, IteratorEltype
using Base: BitSigned
using Base.Checked: checked_neg
using IntegerMathUtils

export isprime, primes, primesmask, factor, ismersenneprime, isrieselprime,
nextprime, nextprimes, prevprime, prevprimes, prime, prodfactors, radical, totient
Expand Down Expand Up @@ -176,11 +177,7 @@ julia> isprime(big(3))
true
```
"""
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp),
Cint, (Any, Cint), x, reps) > 0
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.

isprime(x::BigInt, reps=25) = is_probably_prime(x; reps=reps)

# Miller-Rabin witness choices based on:
# http://mathoverflow.net/questions/101922/smallest-collection-of-bases-for-prime-testing-of-64-bit-numbers
Expand Down