Primes.jl
Primes.jl copied to clipboard
Prime numbers in Julia
Earlier primes(0) will through error like "The condition lo ≤ hi must be met." but now primes(0) will return output as look like primes(0,0).
**Problem Statement** primes(0) returns an error. **Desired Behavior** primes(0) returns a 0-element array like primes(0,0) and primes(0,1) do. **Example** ``` julia> primes(0) ERROR: ArgumentError: The condition lo ≤ hi must...
Currently, memory usage of the prime sieve increases linearly with the size of the interval `[lo, hi]`, while the number of primes only grows asymptotically as `(hi) / log (hi)`....
Cf. discussion at https://github.com/JuliaMath/Primes.jl/pull/78#discussion_r352474088. This allows for example `factor(Int[], 123)`. Should we remove `factor(Vector, 123)`, deprecated it? Or should we just remove the generic methods (`factor(::Type{AbstractArray})`, `factor(::Type{AbstractDict})`, etc.) and keep...
``` julia> nextprime(Int256(2)^186) ERROR: InexactError: trunc(Int256, 776096500322445173294029667436835618525483108491085984157372499045210168189608446442688888866620606620268602202040084040440848044843) ``` We're special casing `Int128` to use the BigInt method. Perhaps we should do that more generally for larger integer types?
playing around with `Factorizations` I noticed a bug ``` julia> print(factor(24)) Primes.Factorization(2 => 3, 3 => 1) julia> Primes.Factorization(2 => 3, 3 => 1) ERROR: MethodError: no method matching Primes.Factorization(::Pair{Int64,...