APL (Dyalog Unicode), 15(削除) 15 (削除ここまで) 12 bytes
⌽!(,÷∨)1⊥⍳∘⊢÷⍨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⊥⍳∘⊢÷⍨1⊥!÷⍳ ⍝ Tacit function, argument will be called ⍵.
!⍳ ⍝ Factorial ofRange 1..⍵ ÷⍨÷ ⍝ Divided byDividing
⍳∘⊢ ! ⍝ the vectorfactorial 1..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.
APL (Dyalog Unicode), 15 bytes
⌽!(,÷∨)1⊥⍳∘⊢÷⍨!
Tacit function, taking a single argument ⍵. Saves a byte by removing the ⌽ if we're allowed to print the denominator first.
How:
⌽!(,÷∨)1⊥⍳∘⊢÷⍨! ⍝ Tacit function, argument will be called ⍵.
! ⍝ Factorial of ⍵ ÷⍨ ⍝ Divided by
⍳∘⊢ ⍝ the vector 1..⍵
1⊥ ⍝ Base-1 decode, aka sum;
!( ) ⍝ Using that sum and the factorial of ⍵ as arguments, fork:
∨ ⍝ (GCD
÷ ⍝ dividing
, ⍝ the vector with both arguments)
⌽ ⍝ reversed.
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.
APL (Dyalog Unicode), 15 bytes
⌽!(,÷∨)1⊥⍳∘⊢÷⍨!
Tacit function, taking a single argument ⍵. Saves a byte by removing the ⌽ if we're allowed to print the denominator first.
How:
⌽!(,÷∨)1⊥⍳∘⊢÷⍨! ⍝ Tacit function, argument will be called ⍵.
! ⍝ Factorial of ⍵
÷⍨ ⍝ Divided by
⍳∘⊢ ⍝ the vector 1..⍵
1⊥ ⍝ Base-1 decode, aka sum;
!( ) ⍝ Using that sum and the factorial of ⍵ as arguments, fork:
∨ ⍝ (GCD
÷ ⍝ dividing
, ⍝ the vector with both arguments)
⌽ ⍝ reversed.