This program can calculate factorials up to 442! It also prints the results, using 20 characters per line! The program was originally written by Bjorn Gustavsson and his version appeared in the newsletter of the Swedish club in 1980. [Programbiten 80-4, page 38]
The version presented here has been changed slighty. Modifications include:
To obtain the high precision this program delivers, the following method is used: :fn id=ro.In the program this "other" register is also R00.:efn :lq.
Starting with the number to be "factorialized" in R00, 1.E-10 in R01 and zero in all other registers, R01 is multiplied by R00. Next R00 is decreased by one, and once again R01 is multiplied by R00. This process continues until R01 has an integer part. At that moment the following actions take place:
It should be noted that the integer/fraction truncation takes place for every register in the loop, not just for the last, but that the above mentioned "other" register is only increased by one when the last register of the current loop is greater than one. :elq.
The method described here is implemented in the program in steps 011-056. If you want to find out in detail how it functions, you should change steps 004-005 and 031-032 into "0"\"3" and SST through them several times.
The instructions for this version of the program are:
000 92 RTN 040 29 CP 080 05 5 120 05 5 001 32 X:T 041 67 X=T 081 48 EXC 121 22 INV 002 42 STO 042 00 00 082 00 00 122 44 SUM 003 00 00 043 48 48 083 63 EX* 123 99 99 004 01 1 044 69 OP 084 99 99 124 03 3 005 00 0 045 20 20 085 53 ( 125 77 XòT 006 22 INV 046 63 EX* 086 24 CE 126 00 00 007 28 LOG 047 00 00 087 65 x 127 75 75 008 35 1/X 048 54 ) 088 01 1 128 29 CP 009 48 EXC 049 48 EXC 089 00 0 129 43 RCL 010 01 01 050 00 00 090 82 HIR 130 99 99 011 53 ( 051 48 EXC 091 44 44 131 69 OP 012 48 EXC 052 99 99 092 82 HIR 132 05 05 013 00 00 053 97 DSZ 093 44 44 133 22 INV 014 85 + 054 00 00 094 85 + 134 67 X=T 015 76 LBL 055 00 00 095 01 1 135 00 00 016 32 X:T 056 11 11 096 85 + 136 72 72 017 69 OP 057 53 ( 097 28 LOG 137 81 RST 018 20 20 058 93 . 098 59 INT 138 00 0 019 64 PD* 059 05 5 099 65 x 139 00 0 020 00 00 060 65 x 100 02 2 140 00 0 021 32 X:T 061 48 EXC 101 75 - 141 76 LBL 022 74 SM* 062 99 99 102 59 INT 142 11 A 023 00 00 063 44 SUM 103 82 HIR 143 98 ADV 024 73 RC* 064 99 99 104 34 34 144 69 OP 025 00 00 065 75 - 105 54 ) 145 00 00 026 59 INT 066 69 OP 106 97 DSZ 146 50 IxI 027 22 INV 067 05 05 107 00 00 147 99 PRT 028 74 SM* 068 54 ) 108 00 00 148 32 X:T 029 00 00 069 42 STO 109 85 85 149 01 1 030 52 EE 070 00 00 110 63 EX* 150 00 0 031 01 1 071 04 4 111 99 99 151 69 OP 032 00 0 072 93 . 112 42 STO 152 17 17 033 94 +/- 073 49 PRD 113 00 00 153 47 CMS 034 22 INV 074 00 00 114 32 X:T 154 60 DEG 035 52 EE 075 93 . 115 82 HIR 155 04 4 036 97 DSZ 076 82 HIR 116 14 14 156 05 5 037 99 99 077 04 04 117 84 OP* 157 30 TAN 038 00 00 078 69 OP 118 00 00 158 33 Xý 039 16 16 079 20 20 119 93 . 159 86 STF <\pre>The TI-59 Version
User Instructions
The user instructions for this version of the program are:
- Enter the program.
- Enter the number you want to "factorialize" and press A. The program will stop with a flashing\1 in the display.
- Now press 7 EE to start the program in Fast Mode.
- When the program has ended, you can display the result by pressing E, repeatedly followed by R/S. The read-out is complete when a flashing zero appears. Don't forget that the display doesn't show leading zeroes!
Listing of the TI-59 Version
Note that only those steps that have to be changed with respect to the TI-59/PC-100 version are given! .sk
057 25 CLR 064 00 00 071 22 INV 078 65 65 058 81 RST 065 53 ( 072 28 LOG 079 00 0 059 76 LBL 066 73 RC* 073 54 ) 080 69 OP 060 15 E 067 00 00 074 92 RTN 081 68 68 061 43 RCL 068 65 x 075 97 DSZ 082 92 RTN 062 99 99 069 01 1 076 00 00 063 42 STO 070 00 0 077 00 00 .sk 083 00 0 . . . . . . 143 00 0 .sk 144 76 LBL 148 32 X:T 152 17 17 156 05 5 145 11 A 149 01 1 153 47 CMS 157 30 TAN 146 50 IxI 150 00 0 154 60 DEG 158 33 Xý 147 59 INT 151 69 OP 155 04 4 159 86 STF <\pre>The TI-58 Version
User Instructions
The user instructions for this version of the program are:
- Enter the calculate part of the program.
- Enter the number you want to "factorialize" and press A. The program will stop with a flashing one in the display.
- Now press 7 EE to start the program in Fast Mode.
- When the program has ended, you can enter the read-out program.
- The result can now be displayed by pressing E, repeatedly followed by R/S. The read-out is complete when a flashing zero appears. Don't forget that the display doesn't show leading zeroes!
Listing of the TI-58 Version [Calculate Part]
000 92 RTN 020 00 00 040 29 CP 060 00 0 001 32 X:T 021 32 X:T 041 67 X=T 061 00 0 002 42 STO 022 74 SM* 042 00 00 062 00 0 003 00 00 023 00 00 043 48 48 063 00 0 004 01 1 024 73 RC* 044 69 OP 064 00 0 005 00 0 025 00 00 045 20 20 065 76 LBL 006 22 INV 026 59 INT 046 63 EX* 066 11 A 007 28 LOG 027 22 INV 047 00 00 067 50 IxI 008 35 1/X 028 74 SM* 048 54 ) 068 59 INT 009 48 EXC 029 00 00 049 48 EXC 069 32 X:T 010 01 01 030 52 EE 050 00 00 070 05 5 011 53 ( 031 01 1 051 48 EXC 071 69 OP 012 48 EXC 032 00 0 052 49 49 072 17 17 013 00 00 033 94 +/- 053 97 DSZ 073 47 CMS 014 85 + 034 22 INV 054 00 00 074 60 DEG 015 76 LBL 035 52 EE 055 00 00 075 04 4 016 32 X:T 036 97 DSZ 056 11 11 076 05 5 017 69 OP 037 49 49 057 00 0 077 30 TAN 018 20 20 038 00 00 058 81 RST 078 33 Xý 019 64 PD* 039 16 16 059 00 0 079 86 STFListing of the TI-58 Version [Read-out Part]
000 76 LBL 006 53 ( 012 22 INV 018 00 00 001 15 E 007 73 RC* 013 28 LOG 019 06 06 002 43 RCL 008 00 00 014 54 ) 020 00 0 003 49 49 009 65 x 015 91 R/S 021 69 OP 004 42 STO 010 01 1 016 97 DSZ 022 68 68 005 00 00 011 00 0 017 00 00 023 92 RTN <\pre>The TI-66 Version
User Instructions
The user instructions for this version of the program are:
- Set the partitioning to 63.55. [Part 56]
- Enter the calculate part of the program.
- Enter the number you want to "factorialize" and press A. The program will start directly.
- When the program has ended, you can enter the read-out program.
- The result can now be displayed by pressing E, repeatedly followed by R/S. The read-out is complete when a zero with nine decimal points appears. Don't forget that the display doesn't show leading zeroes!
Listing of the TI-66 Version [Calculate Part]
000 29 LBL 016 73 EXC 032 76 INT 048 23 OP 001 10 A 017 F5 00 033 31 INV 049 8A 20 002 76 INT 018 23 OP 034 B4 SM* 050 F3 EX* 003 77 IxI 019 8A 20 035 F5 00 051 F5 00 004 6B CMS 020 3A + 036 1B EE 052 2B ) 005 41 CP 021 29 LBL 037 01 1 053 23 OP 006 32 STO 022 24 X:T 038 00 0 054 94 30 007 F5 00 023 23 OP 039 1A +/- 055 73 EXC 008 01 1 024 8A 20 040 31 INV 056 F5 00 009 00 0 025 F4 PD* 041 1B EE 057 73 EXC 010 31 INV 026 F5 00 042 65 DSZ 058 F6 01 011 75 LOG 027 24 X:T 043 F6 01 059 65 DSZ 012 36 1/X 028 B4 SM* 044 8C 22 060 F5 00 013 73 EXC 029 F5 00 045 41 CP 061 85 15 014 F7 02 030 B3 RC* 046 64 X=T 062 A9 RTN 015 2A ( 031 F5 00 047 CA 52Listing of the TI-66 Version [Read-out Part]
000 29 LBL 007 8A 20 014 31 INV 021 F5 00 001 18 E 008 2A ( 015 75 LOG 022 F5 00 002 33 RCL 009 B3 RC* 016 2B ) 023 FB 06 003 F6 01 010 F5 00 017 25 R/S 024 00 0 004 32 STO 011 3C x 018 23 OP 025 36 1/X 005 F5 00 012 01 1 019 94 30 026 A9 RTN 006 23 OP 013 00 0 020 65 DSZ <\pre>Some last notes about the programs