Skip to content

Commit

Permalink
fix prodfactor(factor(1)) (was an error)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Jun 24, 2017
1 parent e7021b6 commit d9e13db
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
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
Expand Up @@ -341,7 +341,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 d9e13db

Please sign in to comment.