My Math Forum  

Go Back   My Math Forum > College Math Forum > Number Theory

Number Theory Number Theory Math Forum

Thanks Tree2Thanks
  • 2 Post By Greens
LinkBack Thread Tools Display Modes
June 28th, 2019, 12:53 PM   #1
Joined: Jun 2019
From: Italy

Posts: 7
Thanks: 0

Sum of number's number

Hey, I have a number theory problem: determine the sum of the digits of a natural number. I have been thinking about it for a lot time during this days, but I can't still find a solution. Can someone give me an idea or advise me a book/internet site with something useful?

Thank a lot.
Vitty is offline  
June 28th, 2019, 01:48 PM   #2
Global Moderator
Joined: May 2007

Posts: 6,823
Thanks: 723

Add them up? What are you looking for?
mathman is offline  
June 28th, 2019, 03:33 PM   #3
Senior Member
Joined: Jun 2019
From: USA

Posts: 223
Thanks: 99

I can find it modulo 9 no problem.
DarnItJimImAnEngineer is offline  
June 28th, 2019, 05:52 PM   #4
Greens's Avatar
Joined: Oct 2018
From: USA

Posts: 93
Thanks: 66

Math Focus: Algebraic Geometry
This seems pretty brute force, wouldn't surprise me at all if there was something more elegant.

Let each digit $d_i \in \{0,1,2 \dots , 9\}$ be such that

$\displaystyle d_{1}d_{2}d_{3} \dots d_{N} = a \in \mathbb{N}$

(This is concatenation, but also $\displaystyle a= \sum_{i=1}^{N} d_{i}10^{(N-i)}$ )

Then we know $d_1 = floor \left(10^{-(N-1)}a \right)$

Now, we know $a-10^{(N-1)}d_{1} = d_{2}d_{3} \dots d_{N}$

thus $d_{2} = floor \left(10^{-(N-2)} \left(a-10^{(N-1)}d_{1} \right) \right)$

and $d_{3} = floor \left(10^{-(N-3)} \left(a-10^{(N-1)}d_{1} - 10^{(N-2)}d_{2} \right) \right)$

Continuing this strategy leaves

$\displaystyle d_{n} = floor \left( 10^{-(N-n)} \left( a - \sum_{i=1}^{n-1} d_{i}10^{(N-i)} \right) \right) $

So, the sum of digits should be

$\displaystyle \sum_{i=1}^{N}d_{i} = floor \left(10^{-(N-1)}a \right) + \sum_{n=2}^{N} floor \left( 10^{-(N-n)} \left( a - \sum_{i=1}^{n-1} d_{i}10^{(N-i)} \right) \right)$

For $N \geq 2$
Thanks from topsquark and Vitty

Last edited by Greens; June 28th, 2019 at 06:06 PM. Reason: Negative Signs
Greens is offline  
June 28th, 2019, 11:34 PM   #5
Joined: Jun 2019
From: Italy

Posts: 7
Thanks: 0

Thanks for your answer. I tried with another different way:

-Let $\displaystyle d_i \in \{0,1,2 \dots , 9\}$ and $\displaystyle \displaystyle d_{1}d_{2}d_{3} \dots d_{N} = a \in \mathbb{N}$

-Now I know that each digit is generated by: $\displaystyle d_i = \sum_{i=1}^{\left \lfloor log_{10}(A)+1 \right \rfloor}\frac{A\,\, mod\,\, 10^{i}-A\,\, mod\,\, 10^{i-1}}{10^{i-1}}$

-I expand the sum and I obtain: $\displaystyle \frac{A\, mod\,\, 10-A\,\, mod\,\, 1}{1}+\frac{A\, mod\,\, 10^{2}-A\,\, mod\,\, 10}{10}+\cdots +\frac{A\, mod\,\, 10^{i}-A\,\, mod\,\, 10^{i-1}}{10^{i-1}}$

-I have to simplify the denominator so: $\displaystyle \frac{1\cdot (A\, mod\,\, 10-A\,\, mod\,\, 1)}{1}+\frac{10\cdot (\frac{A}{10}\, mod\,\, 10-\frac{A}{10}\,\, mod\,\, 1)}{10}+\cdots +\frac{10^{i-1}\cdot (\frac{A}{10^{i-1}}\, mod\,\, 10-\frac{A}{10^{i-1}}\,\, mod\,\, 1)}{10^{i-1}}$

-I split the term: $\displaystyle A\, \, mod\, \, 10+\frac{A}{10}\, \, mod\, \, 10+\cdots+\frac{A}{10^{i-1}}\, \, mod\, \, 10-(A\, \, mod\, \, 1+\frac{A}{10}\, \, mod\; 1+\cdots +\frac{A}{10^{i-1}}\, \, mod\, \, 1)$

-Now I would have picked up $\displaystyle mod\,\,10$ and $\displaystyle mod\,\,1$: $\displaystyle \left (\sum_{i=1}^{\left \lfloor log_{10}(A)+1 \right \rfloor}\frac{A}{10^{i-1}}\right)\, \, mod\, \, 10-\left (\sum_{i=1}^{\left \lfloor log_{10}(A)+1 \right \rfloor}\frac{A}{10^{i-1}}\right)\, \, mod\, \, 1$; but I can't; some ideas to move forward?

Originally Posted by Greens View Post
$\displaystyle \sum_{i=1}^{N}d_{i} = floor \left(10^{-(N-1)}a \right) + \sum_{n=2}^{N} floor \left( 10^{-(N-n)} \left( a - \sum_{i=1}^{n-1} d_{i}10^{(N-i)} \right) \right)$
Can we move from this sum to a function without $\displaystyle \sum$?
Vitty is offline  

  My Math Forum > College Math Forum > Number Theory

function, number, number theory, sum

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
The number of all combinations of limited number of elements is infinite? Germann Advanced Statistics 1 March 12th, 2019 09:34 AM
The relationships between Prime number and Fibonacci number (Part 2) thinhnghiem Math 0 May 15th, 2018 08:07 AM
Prove a large number of samplings converge to a set of small number of samples thanhvinh0906 Advanced Statistics 3 August 30th, 2017 04:27 PM
natural number multiple of another number if its digit sum equal to that number Shen Elementary Math 2 June 5th, 2014 07:50 AM
Number of Necklace/Bracelets With Fixed Number of Beads UnreasonableSin Number Theory 2 June 13th, 2010 12:03 AM

Copyright © 2019 My Math Forum. All rights reserved.