Bell numbers: Difference between revisions

m
(Easylang)
m (→‎{{header|ALGOL W}}: fixed trans)
 
(3 intermediate revisions by 3 users not shown)
Line 296:
4140.0 5017.0 6097.0 7432.0 9089.0 11155.0 13744.0 17007.0 21147.0
21147.0 25287.0 30304.0 36401.0 43833.0 52922.0 64077.0 77821.0 94828.0 115975.0</pre>
 
=={{header|ALGOL W}}==
{{Trans|ALGOL 68|First 15 numbers only}}
<syntaxhighlight lang="algolw">
begin % show some Bell numbers %
integer MAX_BELL;
MAX_BELL := 15;
begin
procedure showBell ( integer value n, bellNumber ) ;
write( i_w := 2, s_w := 0, n, ": ", i_w := 1, bellNumber );
integer array a ( 0 :: MAX_BELL - 2 );
for i := 1 until MAX_BELL - 2 do a( i ) := 0;
a( 0 ) := 1;
showBell( 1, a( 0 ) );
for n := 0 until MAX_BELL - 2 do begin
% replace a with the next line of the triangle %
a( n ) := a( 0 );
for j := n step -1 until 1 do a( j - 1 ) := a( j - 1 ) + a( j );
showBell( n + 2, a( 0 ) )
end for_n
. end
end.
</syntaxhighlight>
{{out}}
<pre>
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
</pre>
 
=={{header|APL}}==
Line 1,625 ⟶ 1,666:
<syntaxhighlight lang="easylang">
func bell n .
if n < 2
return 1
.
len list[] n
list[1] = 1
Line 4,652 ⟶ 4,690:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./big" for BigInt
import "./fmt" for Fmt
 
var bellTriangle = Fn.new { |n|
3,043

edits