Post Reply 
(12C) Digit Sum
05-03-2018, 06:02 PM (This post was last modified: 05-03-2018 06:05 PM by Dieter.)
Post: #2
RE: (12C) Digit Sum
(05-03-2018 10:50 AM)Gamo Wrote:  In mathematics, the digit sum of a given integer is the sum of all its digits
The digit sum of 84001 is calculated as 8+4+0+0+1 = 13
Register used R1, R2 and R3

Three data registers for such a simple task – Gamo, in January you posted a much better digit sum program for the 11C. With a simple change (X≠0? is not available) it can also be used on the 12C.

BTW, in the current program you should clear R2 before (!) the program sums up the digits there, and not at the end. This can be done without disturbing the stack with a STO 2 STO–2 sequence.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Digit Sum - Gamo - 05-03-2018, 10:50 AM
RE: (12C) Digit Sum - Dieter - 05-03-2018 06:02 PM
RE: (12C) Digit Sum - Dieter - 05-04-2018, 12:11 PM
RE: (12C) Digit Sum - Gamo - 05-10-2018, 12:11 PM
RE: (12C) Digit Sum - Gamo - 01-08-2019, 04:34 AM
RE: (12C) Digit Sum - Thomas Klemm - 01-08-2019, 08:24 AM



User(s) browsing this thread: 2 Guest(s)