# How many 5 digit numbers are there, whose i digit is divisible by i?

For example in the number 34567, the second digit (4) can be divided by 2, but the third digit (5) can't be divided by 3.

I thought that the first digit can be divided by any number as 1,2,3,4,5,6,7,8,9 are all divisible by 1.

The second digit can only be divided by 2, which is 2,4,6,8.

The third digit can only be divided by 3, which is 3,6,9.

The fourth digit can only be divided by 4, which is 4 or 8.

The fifth digit can only be divided by 5.

• Since there are only 90,000 5 digit numbers, your answers will be somewhat too high. For the first digit you have 9 choices, for the second you have 5 (zero is divisible by 2), for the third you have 4, for the fourth you have 3 and for the fifth you have 2 choices. This makes a total of 9*5*4*3*2=1080. – Ronald Oct 19 '18 at 13:34
• Does 0 count as being devisible by a digit? – Alucard Oct 19 '18 at 13:34
• You don't need the factorial the first digit can have 9 values not 9!... moreover other digits could be 0 – ALG Oct 19 '18 at 13:34
• @Alucard: $0$ is divisible by everything -- or at least by everything nonzero. Whenever $n\ne 0$ we have that $0/n=0$ which is an integer. (Number theory and abstract algebra actually favor a slightly different definition according to which $0$ also counts as "divisible by" itself even though $0/0$ is undefined -- but that is a bit subtler). – Henning Makholm Oct 19 '18 at 13:40
• Do you mean that EVERY i'th digit has to be divisible by i? Or only just that one or more has to be? – DaveInCaz Oct 19 '18 at 15:35

For the first position we have 9 choices 1,2,3,.....,9 (we cannot include 0 as we want 5 digit number).

For the second postion we have 5 choices 0,2,4,6,8 (here we don’t have problem in including 0).

Similarly for third, forth and fifth position we have 4, 3 and 2 choices respectively.

Now by multiplication rule in combinatorics (no need to take factorial)

We have total 9*5*4*3*2=1080 such numbers.

Answer to the second question is correct.

There are two mistakes:

1. $$0$$ is divisible by each number, therefore it can be selected on every position (except the first one, because then we wouldn't get 5-digit number)
2. There is no point in using permutations.