# Sum of the digits of $N=5^{2012}$

The sum of the digits of $N=5^{2012}$ is computed.

The sum of the digits of the resulting sum is then computed.

The process of computing the sum is repeated until a single digit number is obtained.

What is this single digit number?

• It is either $1$ or $2$ or $4$ or $5$ or $7$ or $8$. – barak manos Nov 10 '16 at 7:11

You want to know the value of $5^{2012} \pmod 9$.

Since $\varphi(9) = 3^2 - 3 = 6$ and $\gcd(5,9) = 1$, then, by Euler's theorem, $5^6 \equiv 1 \pmod 9$.

Since $2012 = 335 \times 6 + 2$, $$5^{2012} \equiv (5^6)^{335} \times 5^2 \equiv 1^{335} \times 25 \equiv 7 \pmod 9.$$

• Hmmm, this one is the best answer here (most definitely better than mine)... – barak manos Nov 10 '16 at 8:25

If Euler's Theorem is unknown then we can instead use the Binomial Theorem. By casting nines the iterated digit sum equals the remainder mod $9$, which we may compute mentally as follows

${\rm mod}\ \color{#c00}9\!:\,\ 5^n\equiv (-4)^n \equiv (-1)^n (1+3)^n \equiv (-1)^n(1 + 3n+ \color{#c00}{3^2}(\cdots))\equiv (-1)^n(1+3n)$

therefore $\ n = 2012\,\Rightarrow\,5^n \equiv 1+3(2012)\equiv 1+3\,\underbrace{(2\!+\!0\!+\!1\!+\!2)}_{\large \rm cast\ nines}\equiv 16\equiv 7\,\pmod 9$

Hint : You can prove that if $d(n)$ denotes sum of digits of $n$, then $n$ is congruent to $d(n)$ mod 9. Also, $N<10^{2012}$ implies $d(N)<9*2012<20000$.

Hint: if $s$ is the sum of digits of a number $a$ then $$s\equiv a\pmod 9.$$ Now all you need too do is compute $5^{2012} \pmod 9$.

Let $f(n)$ denote the sum of sum of ... sum of digits of $5^n$, then:

$f(n)=\cases { 1 &$n\equiv0\pmod6$\\ 5 &$n\equiv1\pmod6$\\ 7 &$n\equiv2\pmod6$\\ 8 &$n\equiv3\pmod6$\\ 4 &$n\equiv4\pmod6$\\ 2 &$n\equiv5\pmod6$\\ }$

Therefore: $2012\equiv2\pmod6 \implies f(2012)=7$.