Post Reply 
(42S) Big Factorial
12-17-2024, 10:43 PM (This post was last modified: 12-17-2024 11:07 PM by Thomas Klemm.)
Post: #6
RE: (42S) Big Factorial
I would have liked to use Werner's excellent program with:
Code:
07 1ᴇ1
Unfortunately that doesn't work.

Therefore I use:
Code:
07 1ᴇ2

But now we have to split 2-digit numbers and align them with:
Code:
00 { 72-Byte Prgm }
01▸LBL "ALIGN"
02 10
03 ÷
04 ENTER
05 IP
06 STO "."
07 DIM?
08 STO+ ST X
09 X<>Y
10 DIM "."
11 R↓
12 R↓
13 FP
14 10
15 ×
16 TRANS
17 INDEX "."
18 I+
19 PUTM
20 RCL "."
21 TRANS
22 STO "."
23 DIM?
24 ×
25 1
26 DIM "."
27 EDITN "."
28 X=0?
29 DELR
30 EXITALL
31 48
32 STO+ "."
33 END

The variable "." now contains all the digits in a \(n \times 1\) matrix.
The value 48 was added because that is the value for 0 when using XTOA.

Once we have that, we extract groups of digits for each row and combine them with a shrinking list of spaces in the variable " ".

The input for this program is the number of lines to be printed:
Code:
00 { 66-Byte Prgm }
01▸LBL "TREE"
02 STO 00
03 1
04 STO 01
05 STO 02
06 NEWMAT
07 32
08 +
09 STO " "
10 GTO 01
11▸LBL 00
12 EDITN " "
13 DELR
14 EXITALL
15▸LBL 01
16 CLA
17 RCL " "
18 XTOA
19 INDEX "."
20 RCL 01
21 1
22 STOIJ
23 RCL 02
24 X<>Y
25 GETM
26 XTOA
27 PRA
28 RCL 02
29 STO+ 01
30 2
31 STO+ 02
32 DSE 00
33 GTO 00
34 END

Example

105
XEQ "BIG!"

[ 85×1 Matrix ]

XEQ "ALIGN"

12
XEQ "TREE"

The result is similar to the picture already posted.
However, the trunk built with zeros is missing.
I'm leaving that as an exercise.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(42S) Big Factorial - Thomas Klemm - 12-15-2024, 11:39 PM
RE: (42S) Big Factorial - Werner - 12-16-2024, 03:40 PM
RE: (42S) Big Factorial - Thomas Klemm - 12-16-2024, 05:38 PM
RE: (42S) Big Factorial - Nihotte(lma) - 12-19-2024, 07:38 PM
RE: (42S) Big Factorial - Thomas Klemm - 12-16-2024, 08:52 PM
RE: (42S) Big Factorial - Thomas Klemm - 12-16-2024, 10:54 PM
RE: (42S) Big Factorial - Thomas Klemm - 12-17-2024 10:43 PM
(42S) Tree Factorial - Thomas Klemm - 12-17-2024, 11:03 PM
RE: (42S) Big Factorial - Thomas Klemm - 12-19-2024, 06:56 AM



User(s) browsing this thread: 4 Guest(s)