We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef3a171 commit 2267021Copy full SHA for 2267021
src/Primes.jl
@@ -362,7 +362,7 @@ julia> prodfactors(factor(100))
362
"""
363
function prodfactors end
364
365
-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)
366
prodfactors(factors::Union{AbstractArray, Set, IntSet}) = prod(factors)
367
368
test/runtests.jl
@@ -372,7 +372,8 @@ end
372
end
373
374
for T in (Int, UInt, BigInt)
375
- for n in rand(T(1):T(100000), 10)
+ for n in [T(1); rand(T(2):T(100000), 10)]
376
+ # for n=T(1), must not error out (#51)
377
for C = (Factorization, Vector, Dict)
378
@test prodfactors(factor(C, n)) == n
379
0 commit comments