HP Forums
(33s) OEIS A7612: A(N-1)+Digital Root of A(N-1) - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (33s) OEIS A7612: A(N-1)+Digital Root of A(N-1) (/thread-18678.html)



(33s) OEIS A7612: A(N-1)+Digital Root of A(N-1) - Gerald H - 08-17-2022 03:21 AM

Takes a natural number from the stack & returns A7612(N).

https://oeis.org/A007612

Digital root:

https://www.hpmuseum.org/forum/thread-18672.html

A(N-1)+Digital root of A(N-1), starting from 1.
Preserves stack.

Code:
1.    LBL C
2.    STO N
3.    CLx
4.    RMDR(N:6)
5.    STO P
6.    CLx
7.    2^(P-1)
8.    STO P
9.    CLx
10.    27*IDIV(N:6)+P-FP(P)*9
11.    RTN

C: LN = 71



RE: (33s) OEIS A7612: A(N-1)+Digital Root of A(N-1) - Didier Lachieze - 08-17-2022 06:33 PM

Code:
10.    27*IDIV(N:6)+P-FP(P)*9

Nice formula!

You can combine steps 4 and 7, and save a few steps:

Code:
1.    LBL C
2.    STO N
3.    CLx
4.    2^(RMDR(N:6)-1)
5.    STO P
6.    CLx
7.    27*IDIV(N:6)+P-FP(P)*9
8.    RTN



RE: (33s) OEIS A7612: A(N-1)+Digital Root of A(N-1) - Gerald H - 08-18-2022 04:15 AM

Thank you, Didier.

Here are size & CKSUM for the shortened programme.

Code:
C: LN = 61    CK = 1373

I haven't previously noted the CK due to a confusion with the 35s, where the check sums are meaningless - However, the 33s does not share that fault & the datum is worth noting.