Anonymous user
Lah numbers: Difference between revisions
→{{header|REXX}}: changed REXX program to use the maximum width for each column to minimize screen acreage.
Thundergnat (talk | contribs) m (Add missing parenthesis) |
(→{{header|REXX}}: changed REXX program to use the maximum width for each column to minimize screen acreage.) |
||
Line 149:
lim= abs(lim) /*only use the absolute value of LIM. */
numeric digits max(9, 4*lim) /*(over) specify maximum number in grid*/
max#.= 0
!.=.
@.= /* [↓] calculate values for the grid. */
Line 158:
if k>n | k==0 | n==0 then do; @.n.k= 0 ; iterate; end
@.n.k = (!(n) * !(nm)) % (!(k) * !(km)) % !(n-k) /*calculate a # in the grid.*/
max#.k= max(max#.k, @.n.k)
max#.b= max(max#.b, @.n.k) /*find the maximum value for all rows. */
end /*k*/
end /*n*/
do k=0 for lim+1 /*find max column width for each column*/
max#.a= max#.a + length(max#.k)
end /*k*/
/* [↓] only show the maximum value ? */
w= length(max#.b)
if olim<0 then do; say 'The maximum value (which has ' w " decimal digits):"
say max#
exit /*stick a fork in it, we're all done. */
end /* [↑] the 100th row is when LIM is 99*/
wi= max(3, length(lim+1) ) /*the maximum width of the grid's index*/
say 'row' center('columns',
do r=0 for lim+1; $= /* [↓] display the grid to the term. */
do c=0 for lim+1 until c>=r /*build a row of grid, 1 col at a time.*/
$= $ right(@.r.c,
end /*c*/
say right(r,wi) strip(substr($,2), 'T') /*display a single row of the grid. */
Line 181 ⟶ 186:
{{out|output|text= when using the default input:}}
<pre>
row ══════════════════════════════════════════columns═══════════════════════════════════════════
0
1
2
3
4
5
6
7
8
9
10
11
12
</pre>
{{out|output|text= when using the input of: <tt> -100 </tt>}}
|