Bell numbers: Difference between revisions
Content deleted Content added
Added Algol 68 |
→{{header|Wren}}: BigInt support added since original solution posted. |
||
Line 3,520:
{{trans|Go}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/big" for BigInt
var bellTriangle = Fn.new { |n|
var tri = List.filled(n,
for (i in 0...n)
tri[
for (j in 0...i) tri[i][j] = BigInt.zero
}
tri[1][0] = BigInt.one
for (i in 2...n) {
tri[i][0] = tri[i-1][i-2]
Line 3,536 ⟶ 3,539:
}
var bt = bellTriangle.call(
System.print("First fifteen and fifitieth Bell numbers:")
for (i in 1..15)
Fmt.print("$d: $,i", 50, bt[50][0])
System.print("\nThe first ten rows of Bell's triangle:")
for (i in 1..10)
{{out}}
<pre>
First fifteen and fifitieth Bell numbers:
10:
11:
12:
13:
14:
15:
50: 10,726,137,154,573,358,400,342,215,518,590,002,633,917,247,281
The first ten rows of Bell's triangle:
1
1 2
4,140 5,017 6,097 7,432 9,089 11,155 13,744 17,007 21,147
21,147 25,287 30,304 36,401 43,833 52,922 64,077 77,821 94,828 115,975
</pre>
|