Bell numbers: Difference between revisions
Content added Content deleted
(→{{header|ASIC}}: Added a solution.) |
(→{{header|QuickBASIC}}: Added a solution.) |
||
Line 561: | Line 561: | ||
print n+1, bell(n+1) |
print n+1, bell(n+1) |
||
next n</syntaxhighlight> |
next n</syntaxhighlight> |
||
==={{header|QuickBASIC}}=== |
|||
{{trans|Delphi}} |
|||
<syntaxhighlight lang="qbasic"> |
|||
' Bell numbers |
|||
DECLARE SUB DisplayRow (N%, BellNum&) |
|||
CONST MAXINDEX% = 14 |
|||
DIM A&(MAXINDEX% - 1) |
|||
FOR I% = 0 TO MAXINDEX% - 1 |
|||
A&(I%) = 0 |
|||
NEXT I% |
|||
N% = 0 |
|||
A&(0) = 1 |
|||
DisplayRow N%, A&(0) |
|||
WHILE N% < MAXINDEX% |
|||
A&(N%) = A&(0) |
|||
FOR J% = N% TO 1 STEP -1 |
|||
A&(J% - 1) = A&(J% - 1) + A&(J%) |
|||
NEXT J% |
|||
N% = N% + 1 |
|||
DisplayRow N%, A&(0) |
|||
WEND |
|||
END |
|||
SUB DisplayRow (N%, BellNum&) |
|||
PRINT "B("; |
|||
PRINT USING "##"; N%; |
|||
PRINT ") = "; |
|||
PRINT USING "#########"; BellNum& |
|||
END SUB |
|||
</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> |
|||
==={{header|Visual Basic .NET}}=== |
==={{header|Visual Basic .NET}}=== |