Jump to content

Lah numbers: Difference between revisions

add BQN
(add BQN)
Line 218:
12 0 479001600 2634508800 4390848000 3293136000 1317254400 307359360 43908480 3920400 217800 7260 132 1
</pre>
 
=={{header|BQN}}==
<code>F</code> is a function that computes the factorial of a number. It returns 0 for negative numbers.
 
<code>Lah</code> computes the lah function, called as <code>n Lah k</code>.
 
The last line builds a table where the rows represent <code>n</code> and columns represent <code>k</code>.
<lang bqn>F ← (≥⟜0)◶⟨0,×´1+↕⟩
Lah ← {
𝕨 𝕊 0: 0;
0 𝕊 𝕩: 0;
𝕨 𝕊 1: F 𝕨;
n 𝕊 k:
(n=k)⊑⟨((n ×○F n-1) ÷ k ×○F k-1) (0=⊢)◶÷‿0 F n-k, 1⟩
}
 
•Show Lah⌜˜↕12</lang><lang>┌─
╵ 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0
0 2 1 0 0 0 0 0 0 0 0 0
0 6 6 1 0 0 0 0 0 0 0 0
0 24 36 12 1 0 0 0 0 0 0 0
0 120 240 120 20 1 0 0 0 0 0 0
0 720 1800 1200 300 30 1 0 0 0 0 0
0 5040 15120 12600 4200 630 42 1 0 0 0 0
0 40320 141120 141120 58800 11760 1176 56 1 0 0 0
0 362880 1451520 1693440 846720 211680 28224 2016 72 1 0 0
0 3628800 16329600 21772800 12700800 3810240 635040 60480 3240 90 1 0
0 39916800 199584000 299376000 199584000 69854400 13970880 1663200 118800 4950 110 1
┘</lang>
[https://mlochbaum.github.io/BQN/try.html#code=RiDihpAgKOKJpeKfnDAp4pe24p+oMCzDl8K0MSvihpXin6kKTGFoIOKGkCB7CiAg8J2VqCDwnZWKIDA6IDA7CiAgMCDwnZWKIPCdlak6IDA7CiAg8J2VqCDwnZWKIDE6IEYg8J2VqDsKICBuIPCdlYogazoKICAobj1rKeKKkeKfqCgobiDDl+KXi0Ygbi0xKSDDtyBrIMOX4peLRiBrLTEpICgwPeKKoinil7bDt+KAvzAgRiBuLWssIDHin6kKfQoK4oCiU2hvdyBMYWjijJzLnOKGlTEy Try It!]
 
=={{header|C}}==
236

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.