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; |
do j=0 for HI+1; $= (j==0); jm= j-1 /*JM is used for a shortcut (below). */ |
||
do k=0 for j; _= jm-k /* [↓] calculate a Bell # the easy way*/ |
|||
$= $ + 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) )") = " $ |