Re: HP-12C mini-challenge - Heegner numbers Message #18 Posted by Gerson W. Barbosa on 26 Mar 2011, 10:07 a.m., in response to message #1 by Gerson W. Barbosa
I haven't been able to make my HP-12C any shorter than the 22-step program I presented ealier. However, I've come up with a nicer algorithm (not necessarily less memory consuming though). I've noticed the last seven Heegner numbers can be expressed as:
3 = 1*4 - 1
7 = 2*4 - 1
11 = 3*4 - 1
19 = 5*4 - 1
43 = 11*4 - 1
67 = 17*4 - 1
163 = 41*4 - 1
Notice that 2, 3, 5, 11, 17 and 63 in the sequence of multiplicands above are the Euler's lucky numbers. Since there is not a formula for them this doesn't help much. However, the first differences of the terms of that sequence (1, 1, 2, 6, 6, 24) can be determined by a simple formula:
a(n) = (Floor(3*n/4))!, n=1..6)
The following HP-71B BASIC program illustrates the algorithm:
10 DESTROY ALL @ DISP 1 @ DISP 2
20 A=1
30 FOR N=1 TO 7
40 DISP 4*A-1
50 B=FACT(IP(3*N/4))
60 A=A+B
70 NEXT N
>
>RUN
1
2
3
7
11
19
43
67
163
>
Here is an equivalent 22-step HP-12C program:
01- CLEAR SIGMA ; R2 <- 0
02- SIGMA+ ; R1 <- 1
03- R/S
04- 2
05- R/S
06- 1
07- STO+ 2
08- RCL 1
09- 4
10- *
11- 1
12- -
13- R/S ; 167! will cause the
14- n! ; program to stop here
15- RCL 2
16- 9
17- 12/ ; 3/4
18- *
19- INTG
20- n!
21- STO+ 1
22- GTO 06
Thanks again to all participants. I hope you have enjoyed.
Gerson.
Edited to fix a typo as per Jeff's observation below.
Edited: 26 Mar 2011, 2:43 p.m. after one or more responses were posted
|