Anonymous user
Pascal's triangle: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, optimized the code (for speed), made the code simplier.
m (added whitespace before the TOC (Table Of Contents), added a Task (bold) header. split the task's requirement sentences into paragraphs, used a bigger font for the formula to make it easier to read the superscript, replace <= with ≤.) |
m (→{{header|REXX}}: added/changed comments and whitespace, optimized the code (for speed), made the code simplier.) |
||
Line 3,145:
if nn=='' | nn=="," then nn=10 /*Not specified? Then use the default.*/
N=abs(nn) /*N is the number of rows in triangle.*/
/* [↓] build rows of Pascals' triangle*/
do r=1 for N; rm=r-1 /*Note: the first column is always 1.*/
Line 3,153:
$.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
end /*r*/ /* [↑] R is the row being built.*/
/* [↑] WIDTH: for nicely looking line.*/
width=length($.N) /*width of the last (output) line (row)*/
/*if NN<0, output is written to a file.*/
do r=1 for N; $$=center($.r,
if nn>0 then say
else call lineout
end /*r*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
!:
'''output''' when using the input of: <tt> 11 </tt>
<pre>
|