user
This task is an aggregation of lesser-known factorials that nevertheless have some mathematical use.

Special factorials

| Name | Formula | Example calculation | Links |
| --- | --- | --- | --- |
| Superfactorial | n  sf(n) = ∏ k!                k=1 | sf(4) = 1! × 2! × 3! × 4! = 288 | * Wikipedia * OEIS:A000178 |
| Hyperfactorial | n  *H*(n) = ∏ kk                k=1 | *H*(4) = 11 × 22 × 33 × 44 = 27,648 | * Wikipedia * OEIS:A002109 |
| Alternating factorial | n  af(n) = ∑ (-1)n-ii!                i=1 | af(3) = -12×1! + -11×2! + -10×3! = 5 | * Wikipedia * OEIS:A005165 |
| Exponential factorial | *n*$ = n(n-1)(n-2)... | 4$ = 4321 = 262,144 | * Wikipedia * OEIS:A049384 |

Task

* Write a function/procedure/routine for each of the factorials in the table above.
* Show   sf(*n*),   *H*(*n*),   and   af(*n*)   where   0 ≤ *n* ≤ 9.   Only show as many numbers as the data types in your language can handle. Bignums are welcome, but not required.
* Show   0$,   1$,   2$,   3$,   and   4$.
* Show the number of digits in   5$.   (Optional)
* Write a function/procedure/routine to find the inverse factorial (sometimes called reverse factorial). That is, if   5! = 120,   then   rf(120) = 5.   This function is simply undefined for most inputs.
* Use the inverse factorial function to show the inverse factorials of 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, and 3628800.
* Show   rf(119).   The result should be undefined.

Notes
:   Since the factorial inverse of   **1**   is both   0   and   1,   your function should return   **0**   in this case since it is normal to use the first match found in a series.

See also

* Factorial
* Factorions
* Left factorials
* Multifactorial
* Primorial numbers
* Stirling numbers of the first kind
assistant
```
sub postfix:<!> ($n) {   [*] 1 .. $n }
sub postfix:<$> ($n) { [R**] 1 .. $n }

sub sf ($n) { [*] map {                      $_! }, 1 .. $n }
sub H  ($n) { [*] map {                $_ ** $_  }, 1 .. $n }
sub af ($n) { [+] map { (-1) ** ($n - $_) *  $_! }, 1 .. $n }
sub rf ($n) {
    state @f = 1, |[\*] 1..*;
    $n == .value ?? .key !! Nil given @f.first: :p, * >= $n;
}

say 'sf : ', map &sf , 0..9;
say 'H  : ', map &H  , 0..9;
say 'af : ', map &af , 0..9;
say '$  : ', map *$  , 1..4;

say '5$ has ', 5$.chars, ' digits';

say 'rf : ', map &rf, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800;
say 'rf(119) = ', rf(119).raku;

```

Output:

```
sf : (1 1 2 12 288 34560 24883200 125411328000 5056584744960000 1834933472251084800000)
H  : (1 1 4 108 27648 86400000 4031078400000 3319766398771200000 55696437941726556979200000 21577941222941856209168026828800000)
af : (0 1 1 5 19 101 619 4421 35899 326981)
$  : (1 2 9 262144)
5$ has 183231 digits
rf : (0 2 3 4 5 6 7 8 9 10)
rf(119) = Nil
```