What is the probability that the digit sum of a randomly chosen integer between 0000 and 9999 is divisible by 5? If I have a randomly selected integer between 0000 and 9999, what is the probability that the digit sum of that number is divisible by 5? 
[E.g. 1234 = 1 + 2 + 3 + 4 = 10]
I've started off with knowing that I have 2 options for the last integer, but I'm not sure where to go from there.
 A: 20%, or 1 in 5.
I just counted them all in Excel.
Consider that in each decade there will be 2 numbers divisible by 5.  The first being 0000 and 0005.  Then 0014 and 0019.  And so on until 0091 and 0096.  Then each century will be similar to the first except for a shift like we get with each decade, 0104 & 0109... 0190 & 0195. Likewise with the millennia.  Consequently, the odds remain the same, 1 in 5.
A: Hint: Pick the first three digits randomly first, and then focus on the last one.
It's similar to how the probability of getting the sum $7$ when throwing two dice can be seen to be $\frac16$ by noting that no matter what the first die shows, the result on the second die can make the sum $7$ in exactly one way.
A: Take the sum of the first 3 digits, and divide it by 5. You have either 0, 1, 2, 3, 4, with probabilities p_0, p_1, p_2, p_3, p_4. You could likely prove that p_i = 0.2 for all i, but there is no need. All you need is that sum(p_i) = 1
for any given i, there are two numbers that the last digit could be. For example, if i = 1, the last digit could be 4 or 9. Since 2 digits out of 10 possibles is 20%, for any given sum of the first 3 digits, there is a 20% chance that the total sum is divisible by 5
So you have: 0.2*p_0 + 0.2*p_1 + 0.2*p_2 + 0.2*p_3 + 0.2*p_4 = 0.2*(p_0+p_1+p_2+p_3+p_4) = 0.2*1 = 0.2
so 20% chance
A: In this case we had it easy since the base 10 is a multiple of the divisor 5. What happens if we have $n$ digits in base $B$ and are interested in divisor $d$?
Let $\omega \neq 1$ be a $d$th root of unity, and consider
$$
P(\omega) = \left(\frac{1 + \omega + \omega^2 + \cdots + \omega^{B-1}}{B}\right)^n = \left(\frac{1-\omega^B}{B(1-\omega)}\right)^n.
$$
The coefficient of $\omega^r$ is the probability that the remainder is $r$. We can extract the probability of a zero remainder by going over all roots of unity (using $P(1) = 1$):
$$
\Pr[r=0] = \frac{1}{d} + \frac{1}{d} \sum_{t=1}^{d-1} \left(\frac{1-\omega^{tB}}{B(1-\omega^t)}\right)^n.
$$
It is not immediately clear why this expression is real. The reason is that the terms for $t$ and $d-t$ are complex conjugates (since $\omega^{d-t} = \overline{\omega^t}$).
Perron-Frobenius theory tells us that the norm of the eigenvalues $\frac{1-\omega^{tB}}{B(1-\omega^t)}$ is strictly less than 1, and so the convergence to $1/d$ is exponentially fast.
A: Javi is almost right! Why focus on the last digit?
For example the digit sum of 104 is divisible by 5. So we have to check the possiblities. The smallest sum is zero and the biggest possible sum having four digits is four times nine = 36, as Javi just explained correctly.
Now let's look how many of the possible digit sums are divisible by 5:
0, 5, 10, 15, 20, 25, 30 and finally 35.
So one could assume that P is 8/36 $\approx$ 0,22. But thats not true...
Looking at the digit sums for each decade one will see that there are always only two sums divisable by 5. So the value of 0,2 or 20 % is correct.
A: This is badly written I admit, as I did this quickly. But this script goes through all the numbers from 0 to 9999 and works out the percentage that have a digit sum that is divisible by 5. As you can see, it is bang on 20%. Hope this helps! (written using python)
count = 0
for k in range(10000):
    a = str(k)
    digitsum = 0
    for b in a:
        num = int(b)
        digitsum += num
    if not digitsum%5: # If its divisible by 5
        count += 1

print('Probability of digitsum being divisible by 5 = %s%%'%((count/10000)*100))

(0 is taken to be divisible by 5 here. If you don't want to include it, your probability will be slightly less than 20%)
A: Note: This answer is wrong, see in comments.
The sum of the four random digits will be between 0 and 36. There are seven numbers divisible by five in this range, so the probability is close to 20%, but not quite.
