(50G) Digits sum (50g)
|
04-12-2020, 08:05 PM
(This post was last modified: 05-03-2020 07:37 PM by Gene.)
Post: #1
|
|||
|
|||
(50G) Digits sum (50g)
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 » If you change the number 10 next the command IDIV2 to 8, you will get the sum of digits of the number in base 8, for example 236067 will return 20 and 236067 in base 8 is 751043, the sum of the digits is 20. Returning to base 10, you apply the program again and again until you get to single digit number. For example applying successively the program to 7897869769, we get 76, 13 and 4. I was trying factorials and notice that after 6!, if you reduce to a single digit, this is always 9. I know there are guys out there with better knowledge that can explain this. |
|||
« Next Oldest | Next Newest »
|
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: 1 Guest(s)