Not That Easy

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 2000th number in this list.


The answer is 4315672.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Yash Jain
Apr 9, 2015

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.

I have seen this problem before! I think in some paper of RMO ..

Nihar Mahajan - 6 years, 2 months ago

Log in to reply

Yup RMO 2000

Yash Jain - 6 years, 2 months ago
Carsten Meyer
Apr 27, 2020

Create an increasing list L L of our seven-digit numbers. The list index starts with zero , so we want to find L 1999 L_{1999} . Name the the digits of any number N N in the list. The last digit must not be 5, otherwise N N would be divisable by 5: N = ! ( d 6 , , d 0 ) , d 0 5 N\overset{!}{=}(d_6,\ldots,\:d_0),\qquad d_0\neq 5

The first digits are most significant - let's count the choices n k n_k we have if we fix the first digits d 6 , , d k d_6,\ldots,\:d_k . If the digit 5 is not among the the higher digits, we have k 1 k-1 choices for d 0 d_0 and then ( k 1 ) ! (k-1)! choices for the rest: n k = { k ! 5 { d 6 , , d k } ( k 1 ) ( k 1 ) ! else \begin{aligned} n_k&=\begin{cases} k!&5\in\{d_{6},\:\ldots,\:d_k\}\\[.25em] (k-1)\cdot(k-1)!&\text{else} \end{cases} \end{aligned}

Observe that our list-index can be partitioned using n k n_k : 1999 = 3 600 + 2 96 + 0 18 + 1 4 + 1 2 + 1 1 = 3 5 5 ! + 2 4 4 ! + 0 3 3 ! + 1 2 2 ! + 1 2 ! + 1 1 ! + 0 \begin{aligned} 1999&=3\cdot 600+2\cdot 96+0\cdot 18+1\cdot 4+1\cdot 2+1\cdot 1\\[.5em] &=\red{3}\cdot 5\cdot 5!+\red{2}\cdot 4\cdot 4!+\red{0}\cdot 3\cdot 3!+\red{1}\cdot 2\cdot 2!+\red{1}\cdot 2!+\red{1}\cdot 1!+\red{0} \end{aligned}

Similar to "decimal-to-binary" transformations, the red numbers tell us which index of the remaining smallest digits we have to choose for d k d_k . The following table shows the iterations: d 6 : 3 1 2 3 4 5 6 7 d 5 : 2 1 2 3 5 6 7 d 4 : 0 1 2 5 6 7 d 3 : 1 2 5 6 7 d 2 : 1 2 6 7 d 1 : 1 2 7 d 0 : 0 2 L 1999 = 4315672 \begin{aligned} \begin{array}{rr|rrrrrrr} d_6:&\red{3}& 1& 2& 3& \blue{4}& 5& 6& 7\\ d_5:&\red{2}& 1& 2& \blue{3}& & 5& 6& 7\\ d_4:&\red{0}&\blue{1}& 2& & & 5& 6& 7\\ d_3:&\red{1}& & 2& & & \blue{5}& 6& 7\\ d_2:&\red{1}& & 2& & & & \blue{6}& 7\\ d_1:&\red{1}& & 2& & & & & \blue{7}\\ d_0:&\red{0}& & \blue{2}& & & & & & \end{array} &&&\Rightarrow&&&&L_{1999}=\boxed{4315672} \end{aligned}

Frank Petiprin
Jan 31, 2019
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#Used Python On An IPad

#1) Used a random number generator to find the 4321 numbers ( with the problems restrictions )  on the
# interval [1234567,7654321] 
#2) Performed a Sort
#3) Counted  up  to the number in position 2000 and found 4315627

import random
import array
end = 100000
Snum = [ 0 ] * end

#change seed for different program runs

seed = 9006
random.seed(  seed  )
ind = 0

# Construct the 4321 numbers end times using a random number generator and then eliminated duplicate numbers

for i in range( 0 , end ):  
      New = random.sample( range( 7 ) , 7 )
      Snum[ ind ] = 0
      for j in range( 0 , 7 ):  
        Snum[ ind ] = ( New[ -j + 6 ] + 1 )*10**(  j  ) + Snum[ ind ]

# Dont allow division by 5

      if ( Snum[  ind  ] % 5 != 0 ):
        ind + = 1

# Eliminate Duplicates

 Snum = set( Snum )
 Snum = list( Snum)

#Set up for Sort

Snum = array.array(  ' i ' , Snum  )
Snum = array.array(  ' i ' , sorted( Snum  )  )
print( ' Number Of Elements In Snum ' , len( Snum))
for j in range( 1995 , 2005  ):
    print(  j , Snum[ j ]  )
#End Program

#Program Run

Number Of Elements In Snum 4321

1995 4312657

1996 4312756

1997 4315267

1998 4315276

1999 4315627

2000 4315672

2001 4315726

2002 4315762

2003 4316257

2004 4316527 

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.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...