Skip to content

Commit

Permalink
fix prodfactor(factor(1)) (was an error) (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet authored Jun 27, 2017
1 parent ef3a171 commit 2267021
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ julia> prodfactors(factor(100))
"""
function prodfactors end

prodfactors(factors::Associative) = prod(p^i for (p, i) in factors)
prodfactors{K}(factors::Associative{K}) = isempty(factors) ? one(K) : prod(p^i for (p, i) in factors)
prodfactors(factors::Union{AbstractArray, Set, IntSet}) = prod(factors)

"""
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ end
end

for T in (Int, UInt, BigInt)
for n in rand(T(1):T(100000), 10)
for n in [T(1); rand(T(2):T(100000), 10)]
# for n=T(1), must not error out (#51)
for C = (Factorization, Vector, Dict)
@test prodfactors(factor(C, n)) == n
end
Expand Down

0 comments on commit 2267021

Please sign in to comment.