Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix typos and improve formatting #158

Merged
merged 1 commit into from
Nov 23, 2024
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
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 min_factor(n)
n < 4 && return n
for i in 3:2:isqrt(n)
n%i == 0 && return i
n%i == 0 && return i

Check warning on line 136 in src/Primes.jl

View check run for this annotation

Codecov / codecov/patch

src/Primes.jl#L136

Added line #L136 was not covered by tests
end
return n
end
Expand All @@ -156,14 +156,14 @@
"""
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 @@
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 @@
#

"""
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 @@
_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
Loading