HP Forums
(33s) OEIS A7953: Sum of Digits of N - 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 A7953: Sum of Digits of N (/thread-18670.html)



(33s) OEIS A7953: Sum of Digits of N - Gerald H - 08-16-2022 08:07 AM

Takes a natural number from the stack & returns A7953(N).
Sum of digits of index.
Preserves stack.

Code:
1.    LBL V
2.    STO N
3.    CLx
4.    STO C
5.    LBL U
6.    CLx
7.    RMDR(N:10)
8.    STO+ C
9.    CLx
10.    IDIV(N:10)
11.    STO N
12.    x≠0?
13.    GTO U
14.    RCL+ C
15.    RTN

V: LN = 12
U: LN = 53