# Sum of number's digits

### Sum of number's digits

Hi Math.com, I have a particular problem: determine the sum of the digits of an integer. I tried with this method:

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

-Now I know that each digit is generated by: $$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: $$\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: $$\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: $$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 $$mod\,\,10$$ and $$mod\,\,1$$: $$\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?

Thanks
Matteo

Posts: 1
Joined: Wed Jul 03, 2019 1:08 pm
Reputation: 0