How many five-digit numbers are divisible by $5$, have equal first and last digits, and have a digit-sum divisible by $5$

combinatoricscomputational mathematics

How many numbers of five digits are there to follow the following conditions?

i) The numbers are divisible by $5$
ii) The first and last digit of the number are same
iii) the sum of the digits of the number is divisible by $5$

As the first condition, the last digit of the number must be 0 or 5.
Then the second condition says the first and last digit of the number must be same, so the last digit can't be 0 (as it make the first digit 0 too).

Now, as per third condition, the sum of the digits of the number should be divisible by 5. As The last and first digits are 5, the middle 3 digits should be divided by 5. So, the sum of middle digits should be 0, 5, 10 or 15.

The permutations for 0, 5 and 10 are easy to compute by "stars and bars" formula. But for 15, some of the permutations have digits more than 9,
like 15 = 0 + 0 + 15 = 1 + 1 + 15 = 1 + 0 + 5 and so on.

As I said before,
the number of permutation for 0 is 1.
the number of permutation for 5 is (5+3-1)C(5) = 21.
the number of permutation for 10 is (10+3-1)C(10) -3C2 = 66 – 3 = 63, as
10 = 0+0+10 is also a permutation.

I could not figure how to permute 15.

Best Answer

A number is divisible by $5$ if and only if the first digit is either zero or five.

By (ii), the first digit and the last digit can not be zero. Otherwise, it will not be a five-digit number.

We conclude that both the first digit and the last digit are $5$. Now, we left with three digits in the middle (starting from $000$ to $999$) which means that we have $1000$ choices.

From these $1000$ numbers, we need to exclude those whose sum of digits are not divisible by $5$.

The number of $3$-digit numbers whose sum of digits are divisible by $5$ is $[{\frac{1000}{5}}]=200$ (This is the required result).