hp41programs

e^1 The decimals of e for the HP-41
 

Overview
 

-The number e is defined by the series:  1 + 1/1! + 1/2! + 1/3! + ....... + 1/k! + .....     where  k! = 1*2*3*.....*(k-1)*k
-In the following program, we calculate 7n decimals of e , and the sum is re-written    1+(1+(1/2)(1+(1/3)(1+(1/4)(1+....(1+(1/k))...)))
-The last integer k is given by lines 04 thru 14 which use an approximate and empirical formula to obtain k such that  k.k! > 107n
 ( this formula may certainly be improved ... )
-The results are stored in registers R01 thru Rnn by groups of 7 digits ( add zeros on the left if need be ).
 

Data Registers:             R00 = n ;  R01 to Rnn = the 7n decimals of e
Flags: /
Subroutines: /
 

Program listing
 

 

01  LBL "E^1"
02  CLRG
03  STO 00       
04  7
05  *
06  7
07  +
08  .84
09  Y^X
10  1.36
11  *
12  2
13  +
14  INT
15  STO M
16  SIGN
17  RCL 00       
18   E3
19  /
20  +
21  STO N
22   E7
23  STO O
24  SIGN
25  LBL 01
26  RCL N
27  LASTX
28  ST+ 01
29  CLX
30  LBL 02       
31  ST+ IND Y
32  CLX
33  RCL IND Y
34  RCL M
35  MOD
36  ST- IND Y
37  LASTX
38  ST/ IND Z
39  CLX
40  RCL O
41  *
42  ISG Y
43  GTO 02
44  DSE M
45  GTO 01
46  LASTX       
47  ST+ 01
48  ST/ 01
49  CLA
50  END

 
  ( 82 bytes / SIZE nnn+1 )
 
 

      STACK        INPUTS      OUTPUTS
           X             n             /

 
Example:     To find 70 decimals of e  press  10  XEQ "E^1"  and 4mn20s later, we have the result in registers R01 to R10:

  R01 = 2.7182818     R02 = 2845904     R03 = 5235360     R04 = 2874713     R05 = 5266249
  R06 =    7757247     R07 =   936999     R08 = 5957496     R09 = 6967627     R10 = 7240766          ( R07 is to be read  0936999 )

whence   e = 2.7182818,2845904,5235360,2874713,5266249,7757247,0936999,5957496,6967627,7240766 .....

-This program finds 140 decimals in about 14mn24s
-It can find ( at the most )  2226 decimals with n = 318 , but execution time is probably of the order of 37 hours!