Pascal's triangle: Difference between revisions

m
→‎{{header|REXX}}: added comments in the header section about creating a disk file vs. displaying the triangle. -- ~~~~
m (→‎{{header|REXX}}: removed ''height'' from ''style''. -- ~~~~)
m (→‎{{header|REXX}}: added comments in the header section about creating a disk file vs. displaying the triangle. -- ~~~~)
Line 1,961:
 
=={{header|REXX}}==
There is no pratical limit for this version, triangles up to 46 linesrows have been generated in a
<br>window 620 pixels wide.
<br><br>If the number specified is negative, the output is written to a file instead. Triangles up to
<br>1000 rows have been created. The file created is named: '''PASCALS.n'''
<br>where '''n''' is the absolute value of the number entered.
<lang rexx>/*REXX program to display Pascal's triangle, neatly centered/formatted.*/
/*AKA: Yang Hui's ▲, Khayyam-Pascal ▲, Kyayyam ▲, Tartaglia's ▲ */
numeric digits 300 1000 /*let's be able to handle big ▲. */
arg nnn .; if nnn=='' then nnn=10; n=abs(nn)
a.=1 /*if NN < 0, output is to a file.*/
if n<1 then do; say "***error!*** N can't be non-positive:" n; exit 13;end
mx=!(n-1) / !(n%2) / !(n-1-n%2) /*MX =biggest number in triangle.*/
a.=1
mx=!(n-1)/!(n%2)/!(n-1-n%2) /*MX =biggest number in triangle.*/
w=length(mx) /* W =width of biggest number. */
line.=1
Line 1,986 ⟶ 1,988:
 
do L=1 for n /*show lines in Pascal's triangle*/
if nn>0 then say center(line.L,width) /*either SAY or write.*/
else call lineout 'PASCALS.'n,center(line.L,width)
end /*L*/
exit