Factors of an integer: Difference between revisions
m
→{{header|Julia}}: use eachfactor
m (→{{header|Phix}}: erm, there be 3 of em) |
m (→{{header|Julia}}: use eachfactor) |
||
Line 3,627:
<syntaxhighlight lang="julia">using Primes
""" Return the factors of n, including 1, n """
function factors(n::T)::Vector{T} where T <: Integer
sort(vec(map(prod, Iterators.product((p.^(0:m) for (p,
end
Line 3,649 ⟶ 3,646:
The factors of 53 are: [1, 53]
0.000102 seconds (35 allocations: 1.516 KiB)
The factors of 64 are: [1, 2, 4, 8, 16, 32, 64]
0.000093 seconds (56 allocations: 3.172 KiB)
|