Anonymous user
Pascal's triangle: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, simplified the code, changed wording in the REXX section header.
(added two variants) |
m (→{{header|REXX}}: added/changed comments and whitespace, simplified the code, changed wording in the REXX section header.) |
||
Line 4,582:
generated (without wrapping) in a screen window with a width of 620 characters.
If the number (of rows) specified is negative, the output is written to a (disk) file
instead. Triangles with over a 1,000 rows have
<br>The output file created (that is written to disk) is named '''PASCALS.n'''
where '''n''' is the absolute value of the number entered.
Line 4,597:
parse arg nn . /*obtain the optional argument from CL.*/
if nn=='' | nn=="," then nn= 10 /*Not specified? Then use the default.*/
w= length( !(
ww= (n-1) * (W + 1) + 1 /*WW: " " " triangle's last row.*/
@.= 1; $.= @.; unity= right(1, w) /*defaults rows & lines; aligned unity.*/
/* [↓] build rows of Pascals' triangle*/
do r=1 for
do c=2 to rm; cm= c-1
@.r.c= @.rm.cm + @.rm.c
$.r = $.r
if r\==1 then $.r= $.r unity
/* [↑] WIDTH: for nicely looking line.*/
if nn>0 then say $$ /*SAY if NN is positive, else */
else call lineout 'PASCALS.'n, $$ /*write this Pascal's row ───► a file.*/
Line 4,617 ⟶ 4,616:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
!: procedure; !=1; do j=2 to arg(1); != !*j; end /*j*/; return !
{{out|output|text= when using the input of: <tt> 11 </tt>}}
<pre>
|