user
Consider the list of factors (divisors) of an integer, such as 12. The factors of 12 are [1, 2, 3, 4, 6, 12]. Consider all sorted sequences of the factors of n such that each succeeding number in such a sequence is a multiple of its predecessor. So, for 6,
we have the factors (divisors) [1, 2, 3, 6]. The 3 unique lists of sequential multiples starting with 1 and ending with 6 that can be derived from these factors are [1, 6], [1, 2, 6], and [1, 3, 6].

Another way to see these sequences is as an set of all the ordered factorizations of a number taken so that their product is that number (excluding 1 from the sequence). So, for 6, we would have [6], [2, 3], and [3, 2]. In this description of the sequences, we are looking at the numbers needed to multiply by, in order to generate the next element in the sequences previously listed in our first definition of the sequence type, as we described it in the preceding paragraph, above.

For example, for the factorization of 6, if the first type of sequence is [1, 6], this is generated by [6] since 1 \* 6 = 6. Similarly, the first type of sequence [1, 2, 6] is generated by the second type of sequence [2, 3] because 1 \* 2 = 2 and 2 \* 3 = 6. Similarly, [1, 3, 6] is generated by [3, 2] because 1 \* 3 = 3 and 3 \* 2 = 6.

If we count the number of such sorted sequences of multiples, or ordered factorizations, and using that count find all integers `n` for which the count of such sequences equals `n`, we have re-created the sequence of the "factor-perfect" numbers (OEIS 163272).

By some convention, on its OEIS page, the factor-perfect number sequence starts with 0 rather than 1. As might be expected
with a sequence involving factorization and combinations, finding factor-perfect numbers becomes
more demanding on CPU time as the numbers become large.

Task

* Show all 48 ordered sequences for each of the two methods for n = 48, which is the first non-trivial factor-perfect number.

According to the paper listed below by P. Erdos, the number of these sequences is

:   F
    (
    n
    )
    =

    ∑

    k
    F
    (


    n

    a

    k
    )
    +
    1
    {\displaystyle F(n)=\sum \_{k}F({\frac {n}{a\_{k}}})+1}

where a is a list of the factors of n, including n, but excluding 1. F(n) is here the same as a function for calculating the number of different factorizations according to the second definition above except that F(1)=0 (where the number of factorizations of 1 must be 1 for it to be included in the sequence of factor-perfect numbers).

* Write a program to calculate and show the first 7 numbers of the factor-perfect numbers.

Stretch task

* Calculate and show more of the subsequent numbers in the sequence.

see also

```
OEIS A163272 (Numbers k such that k = A074206(k), the number of ordered factorizations of k)
OEIS A074206 (Kalmár's [Kalmar's] problem: number of ordered factorizations of n.)
On the maximal order of numbers in the “factorisatio numerorum” problem (Klazar/Luca)
On Some Asymptotic Formulas in The Theory of The "Factorisatio Numerorum" (P. Erdos)

```
assistant
**Translation of**: Wren

```
# 20221029 Raku programming solution

sub propdiv (\x) {
   my @l = 1 if x > 1;
   for (2 .. x.sqrt.floor) -> \d {
      unless x % d { @l.push: d; my \y = x div d; @l.push: y if y != d }
   }
   @l
}

sub moreMultiples (@toSeq, @fromSeq) {
   my @oneMores = gather for @fromSeq -> \j {
      take @toSeq.clone.push(j) if j > @toSeq[*-1] and j %% @toSeq[*-1]
   }
   return () unless @oneMores.Bool;
   for 0..^@oneMores {
      @oneMores.append: moreMultiples @oneMores[$_], @fromSeq
   }
   @oneMores
}

sub erdosFactorCount (\n) {
   state %cache;
   my ($sum,@divs) = 0, |(propdiv n)[1..*];
   for @divs -> \d {
      unless %cache{my \t = n div d}:exists { %cache{t} = erdosFactorCount(t) }
      $sum += %cache{t}
   }
   ++$sum
}

my @listing = moreMultiples [1], propdiv(48);
given @listing { $_.map: *.push: 48; $_.push: [1,48] }
say @listing.elems," sequences using first definition:";
for @listing.rotor(4) -> \line { line.map: { printf "%-20s", $_ } ; say() }

my @listing2 = gather for (0..^+@listing) -> \j {
   my @seq = |@listing[j];
   @seq.append: 48 if @seq[*-1] != 48;
   take (1..^@seq).map: { @seq[$_] div @seq[$_-1] }
}
say "\n{@listing2.elems} sequences using second definition:";
for @listing2.rotor(4) -> \line { line.map: { printf "%-20s", $_ } ; say() }

say "\nOEIS A163272:";
my ($n,@fpns) = 4, 0,1;
while (@fpns < 7) { @fpns.push($n) if erdosFactorCount($n) == $n; $n += 4 }
say ~@fpns;

```

Output:

```
48 sequences using first definition:
1 2 48              1 24 48             1 3 48              1 16 48             
1 4 48              1 12 48             1 6 48              1 8 48              
1 2 24 48           1 2 16 48           1 2 4 48            1 2 12 48           
1 2 6 48            1 2 8 48            1 2 4 24 48         1 2 4 16 48         
1 2 4 12 48         1 2 4 8 48          1 2 4 12 24 48      1 2 4 8 24 48       
1 2 4 8 16 48       1 2 12 24 48        1 2 6 24 48         1 2 6 12 48         
1 2 6 12 24 48      1 2 8 24 48         1 2 8 16 48         1 3 24 48           
1 3 12 48           1 3 6 48            1 3 12 24 48        1 3 6 24 48         
1 3 6 12 48         1 3 6 12 24 48      1 4 24 48           1 4 16 48           
1 4 12 48           1 4 8 48            1 4 12 24 48        1 4 8 24 48         
1 4 8 16 48         1 12 24 48          1 6 24 48           1 6 12 48           
1 6 12 24 48        1 8 24 48           1 8 16 48           1 48                

48 sequences using second definition:
2 24                24 2                3 16                16 3                
4 12                12 4                6 8                 8 6                 
2 12 2              2 8 3               2 2 12              2 6 4               
2 3 8               2 4 6               2 2 6 2             2 2 4 3             
2 2 3 4             2 2 2 6             2 2 3 2 2           2 2 2 3 2           
2 2 2 2 3           2 6 2 2             2 3 4 2             2 3 2 4             
2 3 2 2 2           2 4 3 2             2 4 2 3             3 8 2               
3 4 4               3 2 8               3 4 2 2             3 2 4 2             
3 2 2 4             3 2 2 2 2           4 6 2               4 4 3               
4 3 4               4 2 6               4 3 2 2             4 2 3 2             
4 2 2 3             12 2 2              6 4 2               6 2 4               
6 2 2 2             8 3 2               8 2 3               48                  

OEIS A163272:
0 1 48 1280 2496 28672 29808
```