The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(42S) Big Factorial
12-15-2024, 11:39 PM
Post: #1
(42S) Big Factorial
This program allows to calculate all digits of \(n!\):
Code:
00 { 61-Byte Prgm }
01▸LBL "BIG!"
02 STO 01
03 RCL "1"
04▸LBL 00
05 RCL× 01
06 ENTER
07 RCL÷ 00
08 IP
09 STO "."
10 RCL× 00
11 -
12 INDEX "."
13 J+
14 ENTER
15 DIM?
16 RCL- ST Y
17 GETM
18 STO "."
19 DIM?
20 RCL+ ST Y
21 DIM "."
22 R↓
23 R↓
24 RCL+ "."
25 DSE 01
26 GTO 00
27 END

Question

Is there a better way to shift the elements of an array to the left?

Initialisation

We create an array 1 of length 10 and use 10 digits in each element.

1 ENTER 10 NEWMAT
EDIT

1
EXIT
STO "1"

E 10 STO 00

Example

69
XEQ "BIG!"

[ 1×10 Matrix ]

171'122'452
4'281'413'113
7'246'833'888
1'272'839'092
2'705'448'935
2'036'939'364
8'040'923'257
2'797'541'406
4'742'400'000
0


Compare this to:

69! = 171122452'4281413113'7246833888'1272839092'2705448935'2036939364'8040923257'2797​541406'4742400000'0000000000

Here we use 10 digits for each element of the array.
For higher values of \(n\) this needs to be reduced accordingly.
The result of multiplying by \(n\) must fit into the 12 digits provided by the HP-42S.

Using Free42 with its 34 decimal digits allows to calculate \(1000!\) without further adjustments.
You just have to create the array 1 as a [ 1×257 Matrix ].
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: 1 Guest(s)