Bell numbers: Difference between revisions

Added 11l
m (Reverted edits by Gerard Schildberger (talk) to last revision by Peak)
(Added 11l)
Line 31:
:* '''[[oeis:A000110|OEIS:A000110 Bell or exponential numbers]]'''
:* '''[[oeis:A011971|OEIS:A011971 Aitken's array]]'''
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>F bellTriangle(n)
[[BigInt]] tri
L(i) 0 .< n
tri.append([BigInt(0)] * i)
tri[1][0] = 1
L(i) 2 .< n
tri[i][0] = tri[i - 1][i - 2]
L(j) 1 .< i
tri[i][j] = tri[i][j - 1] + tri[i - 1][j - 1]
R tri
 
V bt = bellTriangle(51)
print(‘First fifteen and fiftieth Bell numbers:’)
L(i) 1..15
print(‘#2: #.’.format(i, bt[i][0]))
print(‘50: ’bt[50][0])
print()
print(‘The first ten rows of Bell's triangle:’)
L(i) 1..10
print(bt[i])</lang>
 
{{out}}
<pre>
First fifteen and fiftieth Bell numbers:
1: 1
2: 1
3: 2
4: 5
5: 15
6: 52
7: 203
8: 877
9: 4140
10: 21147
11: 115975
12: 678570
13: 4213597
14: 27644437
15: 190899322
50: 10726137154573358400342215518590002633917247281
 
The first ten rows of Bell's triangle:
[1]
[1, 2]
[2, 3, 5]
[5, 7, 10, 15]
[15, 20, 27, 37, 52]
[52, 67, 87, 114, 151, 203]
[203, 255, 322, 409, 523, 674, 877]
[877, 1080, 1335, 1657, 2066, 2589, 3263, 4140]
[4140, 5017, 6097, 7432, 9089, 11155, 13744, 17007, 21147]
[21147, 25287, 30304, 36401, 43833, 52922, 64077, 77821, 94828, 115975]
</pre>
 
=={{header|Ada}}==
1,481

edits