Anonymous user
Catalan numbers: Difference between revisions
m
→{{header|REXX}}: simplified two subroutines -- ~~~~
m (→{{header|REXX}}: added comments, added whitespace, indented subroutine fences. -- ~~~~) |
m (→{{header|REXX}}: simplified two subroutines -- ~~~~) |
||
Line 2,154:
/*──────────────────────────────────catalan method 2────────────────────*/
catalan2: procedure expose
s=0; do j=0 to n-1
s=s + catalan2(j) * catalan2(n-j-1) /*recursive invokes.*/
Line 2,162:
/*──────────────────────────────────catalan method 3────────────────────*/
catalan3: procedure expose
c.n=(4*n-2) * catalan3(n-1) % (n+1) /*use REXX memoization technique.*/
return c.n
|