# All the 7-digit numbers containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once, and not divisible by 5

All the 7-digit numbers containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once, and not divisible by 5, are arranged in the increasing order. Find the 2000-th number in this list.

My try:

The number of 7-digit numbers with 1 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720.The number of 7-digit numbers with 1 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720.

• Since this is a site that encourages and helps with learning, it is best if you show your own ideas and efforts in solving the question. Can you edit your question to add your thoughts and ideas about it?
– 5xum
Jun 6, 2016 at 11:48
• How many such numbers do you think there are with first digit 1? Jun 6, 2016 at 11:48
• The number of 7-digit numbers with 1 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720. Jun 6, 2016 at 11:50
• I am sorry for my late reply........i am not very well accoustomed with SE sites @5xum Jun 6, 2016 at 11:52

Observe the following:

• There are $6!-5!=600$ numbers starting with $1$
• There are $6!-5!=600$ numbers starting with $2$
• There are $6!-5!=600$ numbers starting with $3$
• There are $6!-5!=600$ numbers starting with $4$

So your number is the $200$th number which starts with $4$:

• There are $5!-4!=96$ numbers starting with $41$
• There are $5!-4!=96$ numbers starting with $42$
• There are $5!-4!=96$ numbers starting with $43$

So your number is the $8$th number which starts with $43$:

• There are $4!-3!=18$ numbers starting with $431$

So your number is the $8$th number which starts with $431$:

• There are $3!-2!=4$ number starting with $4312$
• There are $3!-2!=4$ number starting with $4315$

So your number is the last number which starts with $4315$.

Therefore your number is $4315762$.

The number of 7-digit numbers with 1 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720. But 120 of these end in 5 and hence are divisible by 5. Thus the number of 7-digit numbers with 1 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once but not divisible by 5 is 600. Similarly the number of 7-digit numbers with 2 and 3 in the left most place and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once but not divisible by 5 is also 600 each. These account for 1800 numbers. Hence 2000-th number must have 4 in the left most place. Again the number of such 7-digit numbers beginning with 41,42 and not divisible by 5 is 120 − 24 = 96 each and these account for 192 numbers. This shows that 2000-th number in the list must begin with 43. The next 8 numbers in the list are: 4312567, 4312576, 4312657, 4312756, 4315267, 4315276, 4315627 and 4315672. Thus 2000-th number in the list is 4315672. Thanks for the hint @almagest

1 at extreme left and rest 6 numbers can be arranged in 6!=720 ways But 120 numbers end with 5 so 720-120=600

Similarly Starting with 2, 600 numbers

Starting with 3, 600 numbers

Starting with 41, 96 numbers

Starting with 42, 96 numbers

Starting with 4312, 4 numbers

Total 1996 numbers and Next 4 numbers are 4315267, 4315276, 4315627, 4315672,

so 2000th number is 4315672

There will be 6 numbers with 4315 _ _ _ instaed of 4 cause you can fill the remaining three places in 3! ways and as 5 is used earlier only then you don't have to neglect 2 case in which 5 comes last