Sum of number's digits

Sum of number's digits

Postby Matteo » Wed Jul 03, 2019 1:33 pm

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

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

-Now I know that each digit is generated by: [tex]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}}[/tex]

-I expand the sum and I obtain: [tex]\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}}[/tex]

-I have to simplify the denominator so: [tex]\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}}[/tex]

-I split the term: [tex]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)[/tex]

-Now I would have picked up [tex]mod\,\,10[/tex] and [tex]mod\,\,1[/tex]: [tex]\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[/tex]; but I can't; some ideas to move forward?

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

Return to Number Theory

Who is online

Users browsing this forum: No registered users and 1 guest