Skip to content

Commit 58d7546

Browse files
authored
fix
1 parent ff78c81 commit 58d7546

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Primes.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,12 @@ function factor!(n::T, h::AbstractDict{K,Int}) where {T<:Integer,K<:Integer}
257257
num_p = 0
258258
while true
259259
q, r = divrem(n, T(p)) # T(p) so julia <1.9 uses fast divrem for `BigInt`
260-
if r == 0
261-
increment!(h, num_p, p) # h[p] += num_p (about 2x faster, but the speed only matters for small numbers)
262-
break
263-
end
260+
r == 0 || break
264261
num_p += 1
265262
n = q
266263
end
264+
# h[p] += num_p (about 2x faster, but the speed only matters for small numbers)
265+
num_p > 0 && increment!(h, num_p, p)
267266
p*p > n && break
268267
end
269268
n == 1 && return h

0 commit comments

Comments
 (0)