Sum of Digits divisible by $5$ How many $6$ digit numbers can we form by using the digits $0-9$ so that their sum of the digits is divisible by $5 ...$ I tried solving it by making cases for every $6$ numbered groups but it was too long and inefficient .
 A: Since the original question does not restrict repetition, I thought of providing a simple answer for the case where repetition is allowed. 
With repetition, the answer is $\color{blue}{180000}$ with a simple explanation. The first digit cannot be zero, so $9$ ways, the next $4$ digits can be anything, so there are $10$ ways for each of them. Now we get a sum, say $33$ of these digits. We can then only choose $2$ or $7$ as last digit to satisfy the condition.
Thus, there are $9 \times 10^4 \times 2 = 180,000$ numbers where repetition is allowed. 
A: We choose $6$ from $10$ and order does not matter so this can be done in $\frac{10!}{6!4!} = 210$ ways. If this is correct we should be able to try them all by hand.
Using software like Matlab/Octave, we can do this with two rows:
T = (unique(perms([ones(1,6),zeros(1,4)]),'rows'));

This row first builds a vector $[1,1,1,1,1,1,0,0,0,0]$ ( $6$ ones and $4$ zeros ), then it creates all the permutations of that row ( very many! ) then the unique commands reduce the permutations so we only get the combinations.
sum(mod(T*[0:9]',5)==0)

Now the matrix $T$ contains as many rows as combinations, we multiply this matrix with the vector $[0,1,\cdots,9]^T$ which will create a summation at all the positions which contain $1$ in the matrix. Then after this summation, we do mod $5$ on each individual sum, and finally do a comparison with 0 on each element which gives $1$ if the modulus is $0$ and $0$ otherwise. Finally we sum up all these truth values to get a total number of how many cases fulfulled our criteria.
Which gives us the answer $42$.
I'm sorry that this does not give any number theoretical insights, but it could be practical information for how to do calculations with software.

EDIT Turns out there is a better way to do it in just one line which does not waste as many resources.
sum(mod(sum(nchoosek([0:9],6),2),5)==0)

The nchoosek function picks out all combinations of $6$ of the elements of the vector $[0,1,\cdots,9]$ and build a matrix where those vectors are the rows. Then we sum along the rows, then we take modulus $5$ and finally compare to $0$ and sum up the result. So with this approach we don't have to do the "unique" which remove all the redundant permutations, which makes it faster and much less memory intensive.
