Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times.
Perfect numbers are numbers whose divisor sum equals their double or \$\sigma(n) = 2n\$. For example, \$\sigma(6) = 12 = 2\times6\$
Superperfect numbers are numbers whose twice iterated divisor sum equals their double. For example, \$\sigma^2(16) = \sigma(\sigma(16)) = \sigma(31) = 32 = 2\times16\$
\$m\$-superperfect numbers are numbers such that \$\sigma^m(n) = 2n\$ for \$m \ge 1\$. For \$m \ge 3\$, there are no such numbers.
\$(m,k)\$-perfect numbers are numbers such that \$\sigma^m(n) = kn\$. For example, \$\sigma^3(12) = 120 = 12\times10\$, so \12ドル\$ is a \$(3,10)\$-perfect number.
You are to choose one of the following three tasks to do:
- Take three positive integers \$n, m, k\$ and output the \$n\$th \$(m,k)\$-perfect number (0 or 1 indexed, your choice)
- Take three positive integers \$n, m, k\$ and output the first \$n\$ \$(m,k)\$-perfect numbers
- Take two positive integers \$m, k\$ and output all \$(m,k)\$-perfect numbers
You may assume that the inputs will never represent an impossible sequence (e.g. \$m = 5, k = 2\$) and that the sequences are all infinite in length. You may take input in any convenient method.
Note that methods that count up starting from either \$m\$ or \$k\$ are not valid, as they fail for \$(4,4)\$-perfect numbers, the smallest of which is \2ドル\$ (credit to Carl Schildkraut for finding this)
This is code-golf so the shortest code in bytes wins.
Test cases
This lists the first few outputs\${}^*\$ for example inputs of \$(m, k)\$
m, k -> out
3, 10 -> 12, 156, 32704, ...
2, 2 -> 2, 4, 16, 64, 4096, 65536, ...
1, 2 -> 6, 28, 496, 8128, ...
4, 48 -> 160, 455, 5920, ...
3, 28 -> 4480, ...
3, 16 -> 294, 6882, ...
1, 4 -> 30240, 32760, ...
4, 4 -> 2, ...
\${}^*\$: Aka, the outputs I could get from my generating program without timing out on TIO
²and use implicit inputs. It will in that case incorrectly multiply the first input \$m\$ with \1ドル\$ in the first iteration, but I think (based on the test cases, so I'm not sure) \1ドル\$ will never be in the output anyway, so it shouldn't matter. But it's likely a counter-example could be found where it might incorrectly result in truthy for \1ドル\$ if you have \$m\$ instead of \$k\$ in the first iteration? Not sure how to prove or disprove my hunch. \$\endgroup\$∞ʒ¹FÑO}y/Q? (Not sure how floating point inaccuracies might affect the results, though.) \$\endgroup\$