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!