Skip to content

Commit

Permalink
changed documentation of isprime(n::Integer) -> Bool
Browse files Browse the repository at this point in the history
- shows exactly when probabilistic methods are applied and when not
- mentions the used methods

changed documentation of isprime(x::BigInt, [reps = 25]) -> Bool
- stated where the function is_probably_prime comes from
  and explains what it does
  • Loading branch information
fepaul committed Nov 15, 2023
1 parent fef5fcd commit f018f68
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,15 @@ end
"""
isprime(n::Integer) -> Bool
Returns `true` if `n` is prime, and `false` otherwise.
Returns for INT64: `true` if `n` is prime, and `false` otherwise
for BigInt: `true` if `n` is probably prime, and `false` otherwise (false-positive rate = 0.25^reps with reps=25)
More detailed:
for even numbers: returns deterministic and correct results
for numbers in the INT 64 range: returns deterministic and correct results (by Lookup-tables, trial-division, Miller-Rabin, Lucas-Test)
for BigInt: returns probabilistic results by using Miller-Rabin from GNU Multiple Precision Arithmetic Library
with reps=25, false-positive rate = 0.25^reps (considerered safe)
```julia
julia> isprime(3)
true
Expand Down Expand Up @@ -290,6 +297,10 @@ end
Probabilistic primality test. Returns `true` if `x` is prime with high probability (pseudoprime);
and `false` if `x` is composite (not prime). The false positive rate is about `0.25^reps`.
`reps = 25` is considered safe for cryptographic applications (Knuth, Seminumerical Algorithms).
is_probably_prime is inherited from the module IntegerMathUtils that provides a wrapper to access
functionality from the GNU Multiple Precision Arithmetic Library (GMP) library, which performs a
- Baillie-PSW probable prime test, then reps-24 Miller-Rabin probabilistic primality tests
```julia
julia> isprime(big(3))
true
Expand Down

0 comments on commit f018f68

Please sign in to comment.