12
\$\begingroup\$

A superior highly composite number is an integer where the ratio of its count of divisors to some power of the number is as high as possible. Expressing this as a formula:

Let d(n) be the number of divisors of n, including the number itself. For a given integer n, if there exists a number e such that d(n)/n^e is greater than or equal to d(k)/k^e for every integer k, then n is a highly composite number.

For more, see Superior highly composite number at Wikipedia, or A002201 at OEIS.

Here are the initial values:

2, 6, 12, 60, 120, 360, 2520, 5040, 55440, 720720, 1441440, 4324320, 21621600, 367567200, 6983776800, 13967553600, 321253732800, 2248776129600, 65214507758400, 195643523275200, 6064949221531200

Your challenge is to take an index n, and output the nth number in this sequence.

You may use 0 or 1 indexing, and you may make a program which is only correct up to the limits of your language's data type(s), as long as it can handle the first 10 values at a minimum.

This is code golf. Standard loopholes apply.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Mathematica, 277 bytes

(A=AppendTo;p[f_]:=Module[{p=f[[1]],k=f[[2]]},N[Log[(k+2)/(k+1)]/Log[p]]];m=#;f={{2,1},{3,0}};o=1;l={2};x=Table[p[f[[i]]],{i,o+1}];For[n=2,n<=m,n++,i=Position[x,Max[x]][[1,1]];A[l,f[[i,1]]];f[[i,2]]++;If[i>o,o++;A[f,{Prime[i+1],0}];A[x,p[f[[-1]]]]];x[[i]]=p[f[[i]]]];Times@@l)&

input

[21]

output

6064949221531200

input

[50]

output

247899128073275948560051200231228551175691632580942972608000

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.