Skip to content

Commit

Permalink
docs: fix typos and improve formatting (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo-Gul authored Nov 23, 2024
1 parent 2fd2f7b commit 23df5b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![Build Status](https://github.com/JuliaMath/Primes.jl/workflows/CI/badge.svg)](https://github.com/JuliaMath/Primes.jl/actions?query=workflow%3A%22CI%22+branch%3Amaster)
[![codecov](https://codecov.io/gh/JuliaMath/Primes.jl/graph/badge.svg?token=DI1wpcH9tB)](https://codecov.io/gh/JuliaMath/Primes.jl)


Documentation:
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMath.github.io/Primes.jl/stable)
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://JuliaMath.github.io/Primes.jl/latest)

[![docs stable badge](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMath.github.io/Primes.jl/stable)
[![docs latest badge](https://img.shields.io/badge/docs-latest-blue.svg)](https://JuliaMath.github.io/Primes.jl/latest)

Julia functions for computing prime numbers.
2 changes: 2 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ This package provides functions for computing prime numbers in Julia.
This release is available for Julia versions 1.6 and up.

To install it, run

```julia
using Pkg ; Pkg.add("Primes")
```

from the Julia REPL.
18 changes: 9 additions & 9 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function _generate_min_factors(limit)
function min_factor(n)
n < 4 && return n
for i in 3:2:isqrt(n)
n%i == 0 && return i
n%i == 0 && return i
end
return n
end
Expand All @@ -156,14 +156,14 @@ end
"""
isprime(n::Integer) -> Bool
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)
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 --> considered 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
for bigger values: returns probabilistic resultsfrom GNU Multiple Precision Arithmetic Library
```julia
julia> isprime(3)
true
Expand Down Expand Up @@ -273,7 +273,7 @@ function lucas_test(n::T) where T<:Signed
if isodd(k>>b) == 1
Qk = mod(Qk*Q, n)
U, V = U + V, V + U*D
# adding n makes them even
# adding n makes them even
# so we can divide by 2 without causing problems
isodd(U) && (U += n)
isodd(V) && (V += n)
Expand Down Expand Up @@ -328,9 +328,9 @@ Base.isempty(f::FactorIterator) = f.n == 1
#

"""
eachfactor(n::Integer)->FactorIterator
eachfactor(n::Integer)->FactorIterator
Returns a lazy iterator of factors of `n` in `(factor, multiplicity)` pairs.
This can be very useful for computing multiplicitive functions since for small numbers (eg numbers with no factor `>2^16`),
This can be very useful for computing multiplicative functions since for small numbers (e.g. numbers with no factor `>2^16`),
allocating the storage required for `factor(n)` can introduce significant overhead.
"""
eachfactor(n::Integer) = FactorIterator(n)
Expand Down Expand Up @@ -373,7 +373,7 @@ function iterate(f::FactorIterator{T}, state=(f.n, T(3))) where T
_min_factor(p) == p || continue
num_p = 0
while true
q, r = divrem(n, T(p)) # T(p) so julia <1.9 uses fast divrem for `BigInt`
q, r = divrem(n, T(p)) # T(p) so julia <1.9 uses fast `divrem` for `BigInt`
r == 0 || break
num_p += 1
n = q
Expand Down
2 changes: 1 addition & 1 deletion src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Base.setindex!(f::Factorization{T}, e::Int, p) where T
end

"""
impliments f[p] += e faster
implements f[p] += e faster
"""
function increment!(f::Factorization{T}, e::Int, p) where T
found = searchsortedfirst(f.pe, p=>0, by=first)
Expand Down

0 comments on commit 23df5b3

Please sign in to comment.