Anonymous user
Factors of an integer: Difference between revisions
→{{header|Julia}}: bugfix for prime n
(→{{header|Julia}}: more efficient implementation based on built-in factor function) |
(→{{header|Julia}}: bugfix for prime n) |
||
Line 1,162:
=={{header|Julia}}==
<lang julia>function factors(
f = [one(
for (p,e) in factor(
f = reduce(vcat, f, [f*p^j for j in 1:e])
end
return length(f) == 1 ? [one(n), n] : sort!(f)
end</lang>
Example output:
|