Bell numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added wording to the REXX section header.)
m (→‎{{header|REXX}}: simplified some code.)
Line 219: Line 219:
numeric digits max(9, HI*2) /*crudely calculate the # decimal digs.*/
numeric digits max(9, HI*2) /*crudely calculate the # decimal digs.*/
!.=; @.= 1 /*the FACT function uses memoization.*/
!.=; @.= 1 /*the FACT function uses memoization.*/
do j=0 for HI+1; $= 0; jm= j-1 /*JM is used for a shortcut (below). */
do j=0 for HI+1; $= (j==0); jm= j-1 /*JM is used for a shortcut (below). */
if j==0 then $= 1 /*use fiat value for the first Bell #. */
do k=0 for j; _= jm-k /* [↓] calculate a Bell # the easy way*/
else do k=0 for j; _= jm-k /* [↓] calculate a Bell # the easy way*/
$= $ + comb(jm,k) * @._ /*COMB≡combination or binomial function*/
$= $ + comb(jm,k) * @._ /*COMB≡combination or binomial function*/
end /*k*/
end /*k*/
@.j= $ /*assign the Jth Bell number to @ array*/
@.j= $ /*assign the Jth Bell number to @ array*/
if j>=LO & j<=HI then say ' bell('right(j, length(HI) )") = " $
if j>=LO & j<=HI then say ' bell('right(j, length(HI) )") = " $