Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 17 characters in body
Source Link
J. Sallé
  • 3.5k
  • 10
  • 24

APL (Dyalog Unicode), 15(削除) 15 (削除ここまで) 12 bytes

⌽!(,÷∨)1⊥⍳∘⊢÷⍨1⊥!÷⍳

Try it online! Try it online!

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⊥⍳∘⊢÷⍨!

Try it online!

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⊥!÷⍳

Try it online!

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.
 
Source Link
J. Sallé
  • 3.5k
  • 10
  • 24

APL (Dyalog Unicode), 15 bytes

⌽!(,÷∨)1⊥⍳∘⊢÷⍨!

Try it online!

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.
 

AltStyle によって変換されたページ (->オリジナル) /