Skip to content

Commit

Permalink
Fix primes for non-positive lo values
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloferz committed Aug 1, 2016
1 parent ceaefcd commit ddbc7d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function primes(lo::Int, hi::Int)
lo 3 hi && push!(list, 3)
lo 5 hi && push!(list, 5)
hi < 7 && return list
sizehint!(list, 5 + floor(Int, hi / (log(hi) - 1.12) - lo / (log(max(lo,2)) - 1.12*(lo > 7))) ) # http://projecteuclid.org/euclid.rmjm/1181070157
lo = max(2, lo)
sizehint!(list, 5 + floor(Int, hi / (log(hi) - 1.12) - lo / (log(lo) - 1.12*(lo > 7))) ) # http://projecteuclid.org/euclid.rmjm/1181070157
sieve = _primesmask(max(7, lo), hi)
lwi = wheel_index(lo - 1)
@inbounds for i = 1:length(sieve) # don't use eachindex here
Expand Down

0 comments on commit ddbc7d6

Please sign in to comment.