Sequence: nth number with exactly n divisors: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 430: | Line 430: | ||
33 : 12166144 |
33 : 12166144 |
||
</pre> |
</pre> |
||
=={{header|Julia}}== |
|||
<lang julia>using Primes |
|||
function countdivisors(n) |
|||
f = [one(n)] |
|||
for (p, e) in factor(n) |
|||
f = reduce(vcat, [f * p ^ j for j in 1:e], init = f) |
|||
end |
|||
length(f) |
|||
end |
|||
function nthwithndivisors(N) |
|||
parray = findall(primesmask(100 * N)) |
|||
for i = 1:N |
|||
if isprime(i) |
|||
println("$i : ", BigInt(parray[i])^(i-1)) |
|||
else |
|||
k = 0 |
|||
for j in 1:100000000000 |
|||
if isodd(i) && Int(floor(sqrt(j)))^2 != j |
|||
continue |
|||
elseif i == countdivisors(j) && (k += 1) == i |
|||
println("$i : $j") |
|||
break |
|||
end |
|||
end |
|||
end |
|||
end |
|||
end |
|||
nthwithndivisors(35) |
|||
</lang>{{out}} |
|||
<pre> |
|||
1 : 1 |
|||
2 : 3 |
|||
3 : 25 |
|||
4 : 14 |
|||
5 : 14641 |
|||
6 : 44 |
|||
7 : 24137569 |
|||
8 : 70 |
|||
9 : 1089 |
|||
10 : 405 |
|||
11 : 819628286980801 |
|||
12 : 160 |
|||
13 : 22563490300366186081 |
|||
14 : 2752 |
|||
15 : 9801 |
|||
16 : 462 |
|||
17 : 21559177407076402401757871041 |
|||
18 : 1044 |
|||
19 : 740195513856780056217081017732809 |
|||
20 : 1520 |
|||
21 : 141376 |
|||
22 : 84992 |
|||
23 : 1658509762573818415340429240403156732495289 |
|||
24 : 1170 |
|||
25 : 52200625 |
|||
26 : 421888 |
|||
27 : 52900 |
|||
28 : 9152 |
|||
29 : 1116713952456127112240969687448211536647543601817400964721 |
|||
30 : 6768 |
|||
31 : 1300503809464370725741704158412711229899345159119325157292552449 |
|||
32 : 3990 |
|||
33 : 12166144 |
|||
34 : 9764864 |
|||
35 : 446265625 |
|||
</pre> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |