APL (Dyalog Unicode), (削除) 15 (削除ここまで) 12 bytes
⌽!(,÷∨)1⊥!÷⍳
Tacit function, taking a single argument ⍵. Saves a byte by removing the ⌽ if we're allowed to print the denominator first.
Thanks @dzaima for 3 bytes.
How:
⌽!(,÷∨)1⊥!÷⍳ ⍝ Tacit function, argument will be called ⍵.
⍳ ⍝ Range 1..⍵
÷ ⍝ Dividing
! ⍝ the factorial of ⍵
1⊥ ⍝ Base-1 decode, aka sum;
!( ) ⍝ Using that sum and the factorial of ⍵ as arguments, fork:
∨ ⍝ (GCD
÷ ⍝ dividing
, ⍝ the vector with both arguments)
⌽ ⍝ reversed.
J. Sallé
- 3.5k
- 10
- 24