Bell numbers: Difference between revisions

Added Algol 68
(added =={{header|Pascal}}== forgot to insert in Feb. 2020)
(Added Algol 68)
Line 183:
21147 25287 30304 36401 43833 52922 64077 77821 94828 115975
</pre>
 
=={{header|ALGOL 68}}==
{{Trans|Delphi}}
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
Uses Algol 68G's LONG LONG INT to calculate the numbers up to 50. Calculates the numbers using the triangle algorithm but without storing the triangle as a whole - each line of the triangle replaces the previous one.
<lang algol68>BEGIN # show some Bell numbers #
PROC show bell = ( INT n, LONG LONG INT bell number )VOID:
print( ( whole( n, -2 ), ": ", whole( bell number, 0 ), newline ) );
INT max bell = 50;
[ 0 : max bell - 2 ]LONG LONG INT a; FOR i TO UPB a DO a[ i ] := 0 OD;
a[ 0 ] := 1;
show bell( 1, a[ 0 ] );
FOR n FROM 0 TO UPB a DO
# replace a with the next line of the triangle #
a[ n ] := a[ 0 ];
FOR j FROM n BY -1 TO 1 DO
a[ j - 1 ] +:= a[ j ]
OD;
IF n < 14 THEN
show bell( n + 2, a[ 0 ] )
ELIF n = UPB a THEN
print( ( "...", newline ) );
show bell( n + 2, a[ 0 ] )
FI
OD
END</lang>
{{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
...
50: 10726137154573358400342215518590002633917247281
</pre>
 
=={{header|ALGOL-M}}==
3,058

edits