Jump to content

Bell numbers: Difference between revisions

→‎{{header|XPL0}}: Added a solution.
(Dialects of BASIC moved to the BASIC section.)
(→‎{{header|XPL0}}: Added a solution.)
Line 4,189:
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>
 
=={{header|XPL0}}==
{{trans|Delphi}}
32-bit integer are required to calculate the first 15 Bell numbers.
{{works with|EXPL-32}}
<syntaxhighlight lang="xpl0">
\Bell numbers
code CrLf=9, IntOut=11, Text=12;
define MaxIndex = 14;
integer A(MaxIndex), I, J, N;
 
begin
for I:= 0 to MaxIndex - 1 do A(I):= 0;
N:= 0; A(0):= 1;
Text(0, "B("); IntOut(0, N); Text(0, ") = "); IntOut(0, A(0)); CrLf(0);
while N < MaxIndex do
begin
A(N):= A(0);
for J:= N downto 1 do A(J - 1):= A(J - 1) + A(J);
N:= N + 1;
Text(0, "B("); IntOut(0, N); Text(0, ") = "); IntOut(0, A(0)); CrLf(0)
end;
end
</syntaxhighlight>
{{out}}
<pre>
B(0) = 1
B(1) = 1
B(2) = 2
B(3) = 5
B(4) = 15
B(5) = 52
B(6) = 203
B(7) = 877
B(8) = 4140
B(9) = 21147
B(10) = 115975
B(11) = 678570
B(12) = 4213597
B(13) = 27644437
B(14) = 190899322
</pre>
 
511

edits

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