Anonymous user
Pascal's triangle: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace, used templates for the output sections.
m (→{{header|REXX}}: added/changed whitespace, used templates for the output sections.) |
|||
Line 4,450:
numeric digits 3000 /*be able to handle gihugeic triangles.*/
parse arg nn . /*obtain the optional argument from CL.*/
if nn=='' | nn=="," then nn=
N= abs(nn)
w= length( !(N-1) / !(N%2) / !(N-1-N%2) )
@.= 1; $.= @.;
/* [↓] build rows of Pascals' triangle*/
do r=1 for N; rm= r-1
do c=2 to rm; cm= c-1
@.r.c= @.rm.cm + @.rm.c /*assign value to a specific row & col.*/
$.r = $.r right(@.r.c, w) /*and construct a line for output (row)*/
end /*c*/ /* [↑] C is the column being built.*/
if r\==1 then $.r= $.r unity
end /*r*/ /* [↑] R is the row being built.*/
/* [↑] WIDTH: for nicely looking line.*/
width= length($.N)
/*if NN<0, output is written to a file.*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
!: procedure; !=1; do j=2 to arg(1); !=!*j; end /*j*/; return ! /*compute factorial*/</lang>
<pre>
1
Line 4,486:
1 10 45 120 210 252 210 120 45 10 1
</pre>
(Output shown at <big>'''<sup>4</sup>/<sub>5</sub>'''</big> size.)
|