Sociable numbers are a generalisation of both perfect and amicable numbers. They are numbers whose proper divisor sums form cycles beginning and ending at the same number. A number is \$n\$-sociable if the cycle it forms has \$n\$ unique elements. For example, perfect numbers are \$1\$-sociable (\$6\to6\to\cdots\$) and amicable numbers are \$2\$-sociable (\$220\to284\to220\to\cdots\$).
Note that the entire cycle must begin and end with the same number. \$25\$ for example is not a \$1\$-sociable number as it's cycle is \$25 \to 6 \to 6 \to \cdots\$, which, despite containing a period \$1\$ cycle, does not begin and end with that cycle.
The proper divisor sum of an integer \$x\$ is the sum of the positive integers that divide \$x\$, not including \$x\$ itself. For example, the proper divisor sum of \$24\$ is \$1 + 2 + 3 + 4 + 6 + 8 + 12 = 36\$
There are currently \$51\$ known \$1\$-sociable numbers, \$1225736919\$ known \$2\$-sociable pairs, no known \$3\$-sociable sequences, \$5398\$ known \$4\$-sociable sequences and so on.
You may choose whether to:
- Take a positive integer \$n\$, and a positive integer \$m\$ and output the \$m\$th \$n\$-sociable sequence
- Take a positive integer \$n\$, and a positive integer \$m\$ and output the first \$m\$ \$n\$-sociable sequences
- Take a positive integer \$n\$ and output all \$n\$-sociable sequences
If you choose either of the last 2, each sequence must have internal separators (e.g. 220, 284
for \$n = 2\$) and distinct, external separators between sequences (e.g. [220, 284], [1184, 1210]
for \$n = 2\$). For either of the first 2, the sequences should be ordered lexicographically.
You can choose whether to include "duplicate" sequences, i.e. the sequences that are the same as others, just beginning with a different number, such as including both 220, 284
and 284, 220
. Please state in your answer if you do this.
The Catalan-Dickson conjecture states that every sequence formed by repeatedly taking the proper divisor sum eventually converges. Your answer may assume this conjecture to be true (meaning that you are allowed to iterate through each integer, testing if it is \$n\$-sociable by calculating if it belongs to an \$n\$-cycle, even though such approaches would fail for e.g. \$276\$ if the conjecture is false).
You may also assume that for a given \$n\$, there exists an infinite number of \$n\$-sociable sequences.
This is code-golf so the shortest code in bytes wins
Test cases
n -> n-sociable sequences
1 -> 6, 28, 496, 8128, ...
2 -> [220, 284], [284, 220], [1184, 1210], [1210, 1184], [2620, 2924], [2924, 2620], [5020, 5564], [5564, 5020], [6232, 6368], [6368, 6232], ...
4 -> [1264460, 1547860, 1727636, 1305184], ...
5 -> [12496, 14288, 15472, 14536, 14264], [14264, 12496, 14288, 15472, 14536], ...
6 -> [21548919483, 23625285957, 24825443643, 26762383557, 25958284443, 23816997477], ...
8 -> [1095447416, 1259477224, 1156962296, 1330251784, 1221976136, 1127671864, 1245926216, 1213138984], ...
9 -> [805984760, 1268997640, 1803863720, 2308845400, 3059220620, 3367978564, 2525983930, 2301481286, 1611969514], ...