user
**Jordan-Pólya numbers** (or **J-P numbers** for short) are the numbers that can be obtained by multiplying together one or more (not necessarily distinct) factorials.

Example

480 is a J-P number because 480 = 2! x 2! x 5!.

Task

Find and show on this page the first **50** J-P numbers.

What is the largest J-P number less than **100 million**?

Bonus

Find and show on this page the **800**th, **1,800**th, **2,800**th and **3,800**th J-P numbers and also show their decomposition into factorials in highest to lowest order. Optionally, do the same for the **1,050**th J-P number.

Where there is more than one way to decompose a J-P number into factorials, choose the way which uses the largest factorials.

Hint: These J-P numbers are all less than 2^53.

References

* Wikipedia article : Jordan-Pólya number
* OEIS sequence A001013: Jordan-Pólya numbers
assistant
**Partial translation of Go**

```
# 20230719 Raku programming solution

my \factorials = 1, | [\*] 1..18; # with 0!

sub JordanPolya (\limit) {
   my \ix = (factorials.keys.first: factorials[*] >= limit) // factorials.end; 
   my ($k, @res) = 2, |factorials[0..ix];

   while $k < @res.elems {
      my \rk = @res[$k];
      for 2 .. @res.elems -> \l {
         my \kl = $ = @res[l] * rk;
         last if kl > limit;
         loop {
            my \p = @res.keys.first: { @res[$_] >= kl } # performance
            if p < @res.elems and @res[p] != kl {
               @res.splice: p, 0, kl
            } elsif p == @res.elems { 
               @res.append: kl 
            }
            kl > limit/rk ?? ( last ) !! kl *= rk
         }
      }
      $k++
   }
   return @res[1..*]
}

my @result = JordanPolya 2**30 ; 
say "First 50 Jordan-Pólya numbers:";
say [~] $_>>.fmt('%5s') for @result[^50].rotor(10);
print "\nThe largest Jordan-Pólya number before 100 million: ";
say @result.first: * < 100_000_000, :end;

```

You may Attempt This Online!