Which Soldier?

100 Soldiers are standing in a circle in the order from 1 to 100. Soldier number 1 has a sword. He kills soldier number 2 and gives the sword to soldier number 3. All the soldiers do the same until only 1 survives. Which soldier (number) will survive in the end?

54 51 29 73 49

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.

9 solutions

Mark Hennings
May 2, 2020

Let J ( n ) J(n) be the number of the surviving soldier when there are n n soldiers in the ring. Of course, J ( 1 ) = 1 J(1) = 1 .

  • If n n is even, after one round, soldiers 2,4,6,...,n will have been killed, so the 1 2 n \tfrac12n soldiers 1,3,5,...,n-1 are left, with the sword back with soldier 1. A soldier in position x x after the first round was in position 2 x 1 2x-1 before the first round. Thus J ( n ) = 2 J ( 1 2 n ) 1 n e v e n J(n) \; = \; 2J(\tfrac12n) - 1 \hspace{2cm} n \;\mathrm{even}
  • If n n is odd, after one round, soldiers 2,4,6,..,n-1,1 will have been killed, so the 1 2 ( n 1 ) \tfrac12(n-1) soldiers 3 , 5 , 7 , . . . , n 3,5,7,...,n are left, with the sword with soldier 3. A soldier in position x x after the first round was in position 2 x + 1 2x+1 before the first round. Thus J ( n ) = 2 J ( 1 2 ( n 1 ) ) + 1 n o d d J(n) \; = \; 2J(\tfrac12(n-1)) + 1 \hspace{2cm} n \;\mathrm{odd}

Now that we have these recurrence relations, we can prove the following by induction:

If n = 2 a + k n = 2^a + k where a , k N { 0 } a,k \in \mathbb{N} \cup \{0\} and 0 k < 2 a 0 \le k < 2^a , then J ( n ) = 2 k + 1 J(n) = 2k+1 .

Proof : If n = 1 n=1 then a = k = 0 a=k=0 , so 2 k + 1 = 1 = J ( 1 ) 2k+1=1=J(1) . Suppose inductively that N > 1 N > 1 and the the above formula works for all numbers smaller than N N .

  • If N = 2 n N = 2n is even, we can write n = 2 a + k n = 2^a + k where 0 k < 2 a 0 \le k < 2^a , so that J ( n ) = 2 k + 1 J(n) = 2k+1 . But then J ( N ) = 2 J ( n ) 1 = 4 k + 1 J(N) = 2J(n) - 1 = 4k+1 . On the other hand N = 2 a + 1 + 2 k N = 2^{a+1} +2k and 0 2 k < 2 a + 1 0 \le 2k < 2^{a+1} , and we note that J ( N ) J(N) is indeed equal to 2 ( 2 k ) + 1 2(2k) + 1 .
  • If N = 2 n + 1 N = 2n+1 is odd, we can write n = 2 a + k n = 2^a + k where 0 k < 2 a 0 \le k < 2^a , so that J ( n ) = 2 k + 1 J(n) = 2k+1 . But then J ( N ) = 2 J ( n ) + 1 = 4 k + 3 J(N) = 2J(n) + 1 = 4k+3 . On the other hand N = 2 a + 1 + ( 2 k + 1 ) N=2^{a+1} + (2k+1) and 0 2 k < 2 a + 1 0 \le 2k < 2^{a+1} , so that 2 k + 1 < 2 a + 1 2k+1 < 2^{a+1} as well, and we note that J ( N ) J(N) is indeed equal to 2 ( 2 k + 1 ) + 1 2(2k+1) + 1 .

Since 100 = 2 6 + 36 100 = 2^6 + 36 , the answer is 73 \boxed{73} .

Solution too bookish it can be done logically without pen and paper

Svsh Singh - 12 months ago
Mahdi Raza
May 2, 2020

100 = 2 a + k a is the highest power 100 = 64 + 36 100 = 2 6 + 36 \begin{aligned} \\ 100 &= 2^a + k \quad a \text{ is the highest power} \\ 100 &= 64 + 36 \\ 100 &= 2^6 + 36 \end{aligned}

The ( 2 k + 1 ) (2k + 1) th person will survive 2 ( 36 ) + 1 73 \implies 2(36) + 1 \implies \boxed{73}


The problem is known as Josephus problem. Watch this excellent video by Numberphile here

Can you please elaborate a little please?

Anshik Kumar Tiwari - 1 year ago

Log in to reply

I have shared a great YouTube video. The video can explain better than I can, so best you watch that. If you have any doubts, I'll surely help if I can.

Mahdi Raza - 1 year ago

Sooooo hard.

YICHEN HU - 1 year ago

Log in to reply

Yup, its pretty hard to understand it.

Rui Chang Lu - 1 year ago

im only a 8 yr old. holy cow.

YICHEN HU - 1 year ago

Log in to reply

It's alright! Have fun looking through my Brilliant page with other interesting problems :)

Rui Chang Lu - 1 year ago

where IS your brilliant page?

YICHEN HU - 1 year ago

Log in to reply

Click my name, it takes you to where I posted all my math problems.

Rui Chang Lu - 1 year ago

Check out numberphiles on YouTube. The video titled “The Josephus Problem” explains this exact problem in great detail.

Joseph Traverso - 10 months, 3 weeks ago

Ok. Thanks!

YICHEN HU - 10 months, 1 week ago
Vinod Kumar
May 23, 2020

The problem is well discussed in "Concrete Mathematics by Graham, Knuth and Patashnik"

The simplest solution is:

First step: Binary representation of 100.  That is 100=1100100

Solution: Cyclic left shift one bit 1001001=73

Does this work everytime ?

Richard Desper
May 5, 2020

Let S i S_i be the set of survivors after the sword has made i i circuits.

First circuit: the even numbers are killed, leaving all the odds for the second circuit. S 1 = { n : n 1 m o d 2 } S_{1} = \{n : n \equiv 1 \mod 2\}

Second circuit: every n n congruent to 1 m o d 4 1 \mod 4 kills the number two higher. S 2 = { n : n 1 m o d 4 } S_{2} = \{n : n \equiv 1 \mod 4\}

Third circuit: every n n kills the number 4 4 higher. S 3 = { n : n 1 m o d 8 } S_{3} = \{n : n \equiv 1 \mod 8\} . Note, however, that S 3 S_3 has an odd number of elements, so our #1 guy is doomed

Fourth circuit: every n n starting with 9 9 kills the number 8 8 higher. S 4 = { n : n 9 m o d 16 } S_{4} = \{n : n \equiv 9 \mod 16\} We're down to 6 6 numbers left.

Fifth circuit: we keep the first, third, and fifth elements of previous set. S 5 = { n : n 9 m o d 32 } = { 9 , 41 , 73 } S_{5} = \{n : n \equiv 9 \mod 32\} = \{9,41,73\}

Sixth circuit: 9 9 kills 41 41 and hands sword to 73 73 . S 6 = { n : n 9 m o d 64 } = { 9 , 73 } S_{6} = \{n : n \equiv 9 \mod 64\} = \{9,73\}

Seventh circuit: 73 73 kills 9 9 and is the sole survivor.

As a newbie to math, I understand the logic (the same train of thought I had used to approach the problem), but don’t understand the math symbols you use, so cannot reproduce it. My fault. Still, thank you for this one!

Jan Papaj - 11 months ago
Rui Chang Lu
May 2, 2020

The solution requires getting the nearest smaller number that is the power of 2, in this case 64 and subtract it with the given number.100-64=36. Now we apply the formula; 2n+1 = 2*36 + 1 = 72 + 1 = 73. Hence answer = 73

Why does this work?

Elijah L - 1 year, 1 month ago

Log in to reply

Have a look at my solution...

Mark Hennings - 1 year, 1 month ago
Ramanujan ∞
Jun 23, 2020
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
a=[]
for i in range(1,101):
    a.append(i)
del a[1::2]
b=a
del b[1::2]
c=b
del c[1::2] 
d=c
del d[0::2]
e=d
del e[1::2]
f=e
del f[1::2]
g=f
del g[::2]
print(g)
#ANSWER IS 73

Soham Nimale
May 20, 2020

Use Euclid's division lemma

First remove 2n

Then remove 4n +3

Then keep cutting until u reach the ans 73

This programme should be able to give us the solution for any number of soldiers, Am I wrong??

def sword(soldiers):

    list = []
    for x in range(soldiers):
        list.append(x+1)
    i = 1
    while len(list) > 1:
        prev = int(list[-1])
        del list[i::2]
        next = int(list[-1])

        #In case the cycle ended with the last soldier dead, the first soldier won't be killed, otherwise, it will.
        if next == prev:
            i = 0
        else:
            i = 1 
     print(list)
Alok Jha
Jun 3, 2020

In every chanceor round alternate guy been killed so it makes an Arithmetic progression

In the first round

1+2( n-1) This shows where the sword goes, in the last sword goes to 99 and he killed 100 and give sword to 1

round 2

1+4(n-1) This shows where the sword goes, the last sword goes to no.97 and he killed 99 and gave sword to 1

3 rd round

1+8( n-1) This shows where the sword goes, in last the sword goes to no. 97 and killed 1 and gave sword to 9 Now the sword goes to 9+16( n-1) if we put n= 5 we get the ans. 73

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...