Post Reply 
Sum of Digits.
03-25-2016, 04:37 PM
Post: #3
RE: Sum of Digits.
Nice programs, here is a shorter version that keeps the stack unchanged excepted for X replaced by it's sum of digits.

Code:
001 LBL'SD'
002 LocR 001
003 SDR 001
004 STO+ .00
005 IP
006 STO- .00
007 x[!=]0?
008 BACK 005
009 x<> .00
010 SDL 001
011 END

Notes: Local registers allocated by LocR are initialized to 0, so no need to clear them. Division and multiplication by a power of 10 can be replaced by the single step instructions SDR and SDL.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Sum of Digits. - ggauny@live.fr - 03-25-2016, 11:16 AM
RE: Sum of Digits. - Dieter - 03-25-2016, 01:41 PM
RE: Sum of Digits. - Didier Lachieze - 03-25-2016 04:37 PM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 05:46 PM
RE: Sum of Digits. - Dieter - 03-25-2016, 06:34 PM
RE: Sum of Digits. - fhub - 03-26-2016, 01:02 PM
RE: Sum of Digits. - Dieter - 03-26-2016, 06:02 PM
RE: Sum of Digits. - fhub - 03-26-2016, 06:17 PM
RE: Sum of Digits. - BarryMead - 03-30-2016, 11:24 AM
RE: Sum of Digits. - Dieter - 03-30-2016, 12:46 PM
RE: Sum of Digits. - BarryMead - 03-30-2016, 07:54 PM
RE: Sum of Digits. - BarryMead - 03-30-2016, 11:11 AM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 07:44 PM
RE: Sum of Digits. - Massimo Gnerucci - 03-25-2016, 08:48 PM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 08:26 PM
RE: Sum of Digits. - Dieter - 03-25-2016, 08:33 PM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 08:37 PM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 08:46 PM
RE: Sum of Digits. - Dieter - 03-25-2016, 08:48 PM
RE: Sum of Digits. - ggauny@live.fr - 03-25-2016, 08:49 PM
RE: Sum of Digits. - Dieter - 03-25-2016, 08:59 PM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 01:17 PM
RE: Sum of Digits. - Dieter - 03-26-2016, 06:16 PM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 07:52 AM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 07:54 AM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 06:22 PM
RE: Sum of Digits. - Dieter - 03-26-2016, 06:27 PM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 08:15 PM
RE: Sum of Digits. - Dieter - 03-26-2016, 09:06 PM
RE: Sum of Digits. - ggauny@live.fr - 03-26-2016, 08:18 PM
RE: Sum of Digits. - ggauny@live.fr - 03-27-2016, 07:10 AM
RE: Sum of Digits. - ggauny@live.fr - 03-29-2016, 11:34 AM
RE: Sum of Digits. - Dieter - 03-29-2016, 07:36 PM
RE: Sum of Digits. - ggauny@live.fr - 03-30-2016, 10:00 AM
RE: Sum of Digits. - Dieter - 03-30-2016, 12:42 PM
RE: Sum of Digits. - ggauny@live.fr - 03-30-2016, 10:04 AM
RE: Sum of Digits. - ggauny@live.fr - 03-30-2016, 05:37 PM
RE: Sum of Digits. - Dieter - 03-30-2016, 06:01 PM
RE: Sum of Digits. - ggauny@live.fr - 03-31-2016, 07:33 AM
RE: Sum of Digits. - Dieter - 03-31-2016, 12:50 PM



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