Skip to content

Commit

Permalink
changed documentation of isprime(n::Integer) -> Bool (#147)
Browse files Browse the repository at this point in the history
* changed documentation of isprime(n::Integer) -> Bool
- 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

---------

Co-authored-by: fepaul <[email protected]>
  • Loading branch information
fepaul-book and fepaul authored Nov 15, 2023
1 parent fef5fcd commit e96d707
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,14 @@ end
"""
isprime(n::Integer) -> Bool
Returns `true` if `n` is prime, and `false` otherwise.
Returns for values in the range of an INT64 variable: `true` if `n` is prime, and `false` otherwise
for bigger values: `true` if `n` is probably prime, and `false` otherwise (false-positive rate = 0.25^reps with reps=25 --> considerered safe)
More detailed:
for even numbers: returns deterministic and correct results
for values in the range of an INT64 variable: returns deterministic and correct results (by Lookup-tables, trial-division, Miller-Rabin, Lucas-Test)
for bigger values: returns probabilistic resultsfrom GNU Multiple Precision Arithmetic Library
```julia
julia> isprime(3)
true
Expand Down Expand Up @@ -290,6 +296,9 @@ 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
```julia
julia> isprime(big(3))
true
Expand Down

0 comments on commit e96d707

Please sign in to comment.