Catalan numbers: Difference between revisions
Content added Content deleted
m (→{{header|BQN}}: Cleaner syntax) |
(add more versions) |
||
Line 716: | Line 716: | ||
=={{header|BQN}}== |
=={{header|BQN}}== |
||
<lang bqn>Cat←{ 0⊸<◶⟨1, (𝕊-⟜1)×(¯2+4×⊢)÷1+⊢⟩ 𝕩 } |
<lang bqn>Cat←{ 0⊸<◶⟨1, (𝕊-⟜1)×(¯2+4×⊢)÷1+⊢⟩ 𝕩 } |
||
Fact ← ×´1+↕ |
|||
⚫ | |||
Cat1 ← { # direct formula |
|||
⌊0.5 + (Fact 2×𝕩) ÷ (Fact 𝕩+1) × Fact 𝕩 |
|||
} |
|||
Cat2 ← { # header based recursion |
|||
0: 1; |
|||
(𝕊 𝕩-1)×2×(1-˜2×𝕩)÷𝕩+1 |
|||
} |
|||
Cat¨ ↕15 |
|||
Cat1¨ ↕15 |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre>⟨ 1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 ⟩</pre> |
<pre>⟨ 1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 ⟩</pre> |