Jump to content

Stirling numbers of the second kind: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments, expaciated the title for the "row".
m (→‎{{header|REXX}}: added/changed whitespace and comments, expaciated the title for the "row".)
Line 1,130:
numeric digits max(9, 2*lim) /*(over) specify maximum number in grid*/
@.=
do j=0 for lim+1
@.j.j = 1; if j==0 then iterate /*define the right descending diagonal.*/
@.0.j = 0; @.j.0 = 0 /* " " zero values. */
end /*j*/
max#.= 0 /* [↓] calculate values for the grid. */
do n=0 for lim+1; np= n + 1
do k=1 for lim; km= k - 1
@.np.k = k * @.n.k + @.n.km /*calculate a number in the grid. */
max#.k= max(max#.k, @.n.k) /*find the maximum value for a column. */
max#.b= max(max#.b, @.n.k) /*find the maximum value for all rows. */
end /*k*/
end /*n*/
/* [↓] only show the maximum value ? */
do k=0 for lim+1 /*find max column width for each column*/
Line 1,152:
exit /*stick a fork in it, we're all done. */
end
wiwgi= max(35, length(lim+1) ) /*the maximum width of the grid's index*/
say 'row═row═' center('"columns'", max(9, max#.a + lim), '═') /*display header of the grid.*/
 
do r=0 for lim+1; $= $= /* [↓] display the grid to the term. */
do c=0 for lim+1 until c>=r /*build a row of grid, 1 col at a time.*/
$= $ right(@.r.c, length(max#.c) ) /*append a column to a row of the grid.*/
end /*c*/
say rightcenter(r,wi wgi) strip( substr($,2), 'T') /*display a single row of the grid. */
end /*r*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
row═row═ ══════════════════════════════columns══════════════════════════════
0 1
1 0 1
2 0 1 1
3 0 1 3 1
4 0 1 7 6 1
5 0 1 15 25 10 1
6 0 1 31 90 65 15 1
7 0 1 63 301 350 140 21 1
8 0 1 127 966 1701 1050 266 28 1
9 0 1 255 3025 7770 6951 2646 462 36 1
10 0 1 511 9330 34105 42525 22827 5880 750 45 1
11 0 1 1023 28501 145750 246730 179487 63987 11880 1155 55 1
12 0 1 2047 86526 611501 1379400 1323652 627396 159027 22275 1705 66 1
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; &nbsp; <tt> -100 </tt>}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.