0

I'm looking for a method to simplify this expression with modulus:

$$A\: mod\: 10\: +\:\left \lfloor\frac{A}{10}\right \rfloor\: mod\: 10\: +\: \left \lfloor\frac{A}{100}\right \rfloor\: mod\: 10\: +\cdots \: +\: \left \lfloor\frac{A}{10^{i}}\right \rfloor\: mod\: 10$$

where $A$ and $i$ are integers and $i\leq \left \lfloor log_{10}{(A)} \right \rfloor$. In others words, we have to evaluate the sum: $$\Xi \:= \sum_{i=0}^{\left \lfloor \log_{10}(A) \right \rfloor}\lfloor\frac{A}{10^{i}}\rfloor\pmod{10} $$

My question is to find a way to express $\Xi$ without $\sum$.

-I have tried to pick up $mod\: 10$ and I have obtained: $$\left (\sum_{i=0}^{\left \lfloor \log_{10}(A) \right \rfloor}\lfloor\frac{A}{10^{i}}\rfloor\right)\, \, \pmod{10}$$

-Now I have recognised the geometric series and I have calculated it's value, by the formula: $$\left ( A\cdot \frac{1-(\frac{1}{10})^{i}}{1-\frac{1}{10}} \right )\: mod\: 10$$

;but it seems it doesn't work. How can I move forward?

N.B: When I talk about find a way of express $\Xi$ without $\sum$ is for instance the one that I explained before with the geometric series.

Matteo
  • 6,581

1 Answers1

1

The function you described returns the sum of the digits of your input $A$. There is no way to write this symbolically without a $\sum$, but you could always use words.

$S(A)=$ The sum of the digits of $A$, for any $A\in \mathbb{N}=\sum_{i=0}^{\left \lfloor \log_{10}(A) \right \rfloor}\lfloor\frac{A}{10^{i}}\rfloor\pmod{10}$

*Note the geometric series formula you used does not work, because it does not account for the floor function.

Anirudh
  • 714