Jump to content

Sequence: smallest number with exactly n divisors: Difference between revisions

→‎{{header|Julia}}: More functional expressions
(→‎{{header|Julia}}: shorter and more efficient numfactors)
(→‎{{header|Julia}}: More functional expressions)
Line 347:
 
=={{header|Julia}}==
{{trans|Perl}}
<lang julia>using Primes
 
numfactors(n) = reduce(*, e+1 for (_,e) in factor(n); init=1)
 
A005179(n) = findfirst(k -> numfactors(k) == n, 1:typemax(Int))
function A005179(N)
println("First $N terms of OEIS sequence A005179: ")
for i in 1:N
j = 0
while (j += 1) > 0
if i == numfactors(j)
print("$j ")
break
end
end
end
end
 
println("FirstThe $Nfirst 15 terms of OEISthe sequence A005179are: ")
A005179(15)
println(map(A005179, 1:15))
</lang>{{out}}
<pre>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.