diff --git a/README.md b/README.md index bd3c8e1..4d2e801 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docs/src/index.md b/docs/src/index.md index d87cd2a..f7cee84 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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. diff --git a/src/Primes.jl b/src/Primes.jl index 6025ae0..3ba8fdc 100644 --- a/src/Primes.jl +++ b/src/Primes.jl @@ -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 @@ -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 @@ -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) @@ -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) @@ -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 diff --git a/src/factorization.jl b/src/factorization.jl index be583ca..48b6bfb 100644 --- a/src/factorization.jl +++ b/src/factorization.jl @@ -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)