Anonymous user
Catalan numbers/Pascal's triangle: Difference between revisions
m
→{{header|REXX}}: fixed handling of default args, changed/added comments and whitespace.
No edit summary |
m (→{{header|REXX}}: fixed handling of default args, changed/added comments and whitespace.) |
||
Line 1,174:
<lang rexx>/*REXX program obtains and displays Catalan numbers from a Pascal's triangle. */
parse arg N . /*Obtain the optional argument from CL.*/
if N=='' | N=="
numeric digits max(9, N%2 + N%8) /*so we can handle huge Catalan numbers*/
@.=0; @.1=1 /*stem array default; define 1st value.*/
do i=1 for N; ip=i+1
do j=i by -1 for N; jm=j-1; @.j=@.j+@.jm; end /*j*/
▲ do k=ip by -1 for N; km=k-1; @.k=@.k+@.km; end /*k*/
say @.ip - @.i /*display the Ith Catalan number. */
end /*i*/ /*stick a fork in it, we're all done. */</lang>
Line 1,206 ⟶ 1,205:
<lang rexx>/*REXX program obtains and displays Catalan numbers from a Pascal's triangle. */
parse arg N . /*Obtain the optional argument from CL.*/
if N=='' | N=="
numeric digits max(9, N%2 + N%8) /*so we can handle huge Catalan numbers*/
@.=0; @.1=1 /*stem array default; define 1st value.*/
do
say @.ip
▲ end /*i*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,223 ⟶ 1,221:
<lang rexx>/*REXX program obtains and displays Catalan numbers from a Pascal's triangle. */
parse arg N . /*Obtain the optional argument from CL.*/
if N=='' | N=="
numeric digits max(9, N%2 + N%8) /*so we can handle huge Catalan numbers*/
do j=1 for N /* [↓] display N Catalan numbers. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,241 ⟶ 1,238:
<lang rexx>/*REXX program obtains and displays Catalan numbers from a Pascal's triangle. */
parse arg N . /*Obtain the optional argument from CL.*/
if N=='' | N=="
numeric digits max(9, N%2 + N%8) /*so we can handle huge Catalan numbers*/
!.=.
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
|