Sum of the digits of $2012^{2012}$ and sum of that sum

decimal-expansionelementary-number-theorymodular arithmetic

I attempted to solve the following problem:

Let $S_1$ be the sum of the digits of $2012^{2012}$ and $S_2$ be the sum of the digits of $S_1$. Find $S_1$ and $S_2$.

Here is what I've got:

Let $n = 2012^{2012}$. Let $k_1$ be the number of digits of $n$. Let $k_2$ be the number of digits of $S_1$.

Finding the number of digits can be done by taking the "ceiling" term (or "floor" term and add $1$) of $\log_{10}n$, this gives:

$k_1=\left \lceil \log_{10}n \right \rceil = 6647$ and $k_2=\left \lceil \log_{10}S_1 \right \rceil$.

The idea I tried to use in order to calculate the sum of the digits is taking the sum of each $i$-th digit times the according power of $10$, for example for $2012$:

$2012= 2 \cdot 10^3+0 \cdot 10^2 + 1 \cdot 10^1 + 2 \cdot 10^0$.

For $S_1$ and $S_2$ this gives:

$S_1=\displaystyle\sum_{i=0}^{k_1-1} \lambda_i \cdot 10^i$ and $S_2=\displaystyle\sum_{i=0}^{k_2-1} \alpha_i \cdot 10^i$.

Then I tried to find a way to express the $\lambda_i$s and $\alpha_i$s, this is what i came up with:

$\lambda_i =\left \lfloor n \cdot 10^{-i} \mod 10 \right \rfloor ,\; i=0,\cdots,k-1$

$\alpha_i =\left \lfloor S_1 \cdot 10^{-i} \mod 10 \right \rfloor ,\; i=0,\cdots,k-1$.

Plugging it back in $S_1$ and $S_2$ gives:

$S_1=\displaystyle\sum_{i=0}^{k_1-1} \left \lfloor n\cdot10^{-i} \mod 10 \right \rfloor \cdot 10^i$

$S_2=\displaystyle\sum_{j=0}^{k_2-1}\sum_{i=0}^{k_1-1}\left( \left\lfloor \left\lfloor n\cdot 10^{-i} \mod 10 \right\rfloor \cdot 10^{i}\cdot 10^{-j} \mod 10 \right\rfloor \cdot 10^j \right) $.

Thank you very much for reading this far, now I have a some questions!

Firstly is this even correct? And if it is, is there a smarter way to calculate $S_1$ and $S_2$ (because with this formulation it clearly isn't possible to calculate by hand, unless you have a lot (a lot) of time to spare) or calculating it will always require a computer?

Apologies for any maths, synthax or english errors!

Best Answer

I don't think there is a hand accessible way to calculate these. Alpha gives $S_1=29383$ and from this it is easy to see $S_2=25$. You have correctly noticed that the sum of digits operator works a lot like a logarithm, so it makes big numbers much smaller. Usually when questions like this are asked there are enough sums taken (three in this case) that you can show the result has a single digit. Then you use the fact that the remainder on division by $9$ is maintained by the sum of digits, so if you can find the value $\bmod 9$ you are done. For this you would say $$2012^{2012}\equiv 5^{2012} \pmod 9\\ 5^6 \equiv 1 \pmod 9\\ 5^{2012}=5^{6\cdot 305+2}\equiv 5^2\equiv 7 \pmod 9$$ which is well within hand calculation.

Related Question