Post Reply 
(50G) Digits sum (50g)
04-13-2020, 08:38 PM
Post: #3
RE: Digits sum (50g)
(04-12-2020 08:05 PM)Juan14 Wrote:  The program below finds the sum of the digits of an integer, for example for 236067 the program returns 2+3+6+0+6+7 = 24.

«
0 SWAP
WHILE DUP
REPEAT
10 IDIV2 ROT + SWAP
END DROP
»

That's a pretty loop
Otherwise, no loop (lol) !

So, Juan14, I propose you this one !? (HP48 : no IDIV2 available)

SUMAD #F010h 97.5
«
10
→ n b
« n b MOD
IF n b ≥ THEN
n b / IP SUMAD +
END
»
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50G) Digits sum (50g) - Juan14 - 04-12-2020, 08:05 PM
RE: Digits sum (50g) - grsbanks - 04-13-2020, 09:45 AM
RE: Digits sum (50g) - Nihotte(lma) - 04-13-2020 08:38 PM
RE: Digits sum (50g) - Juan14 - 04-13-2020, 11:01 PM
RE: Digits sum (50g) - DavidM - 04-15-2020, 03:49 AM
RE: Digits sum (50g) - John Keith - 04-15-2020, 10:21 PM
RE: Digits sum (50g) - DavidM - 04-17-2020, 04:31 AM
RE: Digits sum (50g) - Gerald H - 04-17-2020, 10:42 AM
RE: (50G) Digits sum (50g) - gor1060 - 12-11-2022, 11:15 AM



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