There are people standing in a circle. Each person is numbered in order from to . Person has a sword. He kills the next person( i.e. Person 2) and gives the sword to the next( i.e. Person 3). All people do the same until only 1 survives.
if , which Person survives at the end. Enter that Person number as your answer.
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.
We see that when n is even the sword goes back to the Person 1 after 1 iteration When n is odd the sword goes to the Person n after 1 iteration. In general, at any stage, if number of person is n and sword is with Person p then if n is even, sword will remain with Person p after 1 iteration and number of person will reduce to 2 n and if n is odd, sword will goes to Person p − 1 after 1 iteration and number of person reduces to 2 n + 1 .
On this basis, we conclude that at any stage, if the number of persons is a power of 2 and sword is with Person p , then at the end Person p will survive.
Solving in general,
If n are persons are there, we have to find the value of integral k such that 2 k ≤ n < 2 k + 1 . Now we have to find r such that n = 2 k + r where r will range from 0 to 2 k − 1
r = n − 2 k ⇒ 2 r = 2 n − 2 k + 1 ⇒ 2 r = n + n − 2 k + 1 ≤ n − 1 [ ∵ n < 2 k + 1 ⇒ n − 2 k + 1 < 0 ⇒ n − 2 k + 1 ≤ − 1 ]
This last equation assures that it is possible to kill r persons in 1 s t iteration starting form Person 1 to get the number of person as 2 k that is the power of 2.
Since Person 1 kills Person 2, Person 3 kills Person 4 and so on, so r t h person to die is the Person 2 r who is kiiled by the Person 2 r − 1 and this Person after killing Person 2 r gives the sword to Person 2 r + 1 [ Person 2 r + 1 exists because 2 r + 1 ≤ n ]
Now, sword is with Person 2 r + 1 and there are 2 k persons left. Hence at the end Person 2 r + 1 will survive.
Now finding the value of r in terms of n
We have,
2 k ≤ n < 2 k + 1 ⇒ k ≤ log 2 n < k + 1 ⇒ k = ⌊ log 2 n ⌋
Now r = n − 2 ⌊ log 2 n ⌋
Hence at the end, Person 2 ( n − 2 ⌊ log 2 n ⌋ ) + 1 will survive.
In the question, n is given 1 0 0 5 2 0 2 0 .
⇒ log 2 n = log 2 1 0 0 5 2 0 2 0 = 2 3 . 2 6 1 ⇒ ⌊ log 2 n ⌋ = 2 3 ⇒ 2 ⌊ log 2 n ⌋ = 2 2 3 = 8 3 8 8 6 0 8 ⇒ n − 2 ⌊ log 2 n ⌋ = 1 0 0 5 2 0 2 0 − 8 3 8 8 6 0 8 = 1 6 6 3 4 1 2 ⇒ 2 ( n − 2 ⌊ log 2 n ⌋ ) = 2 ⋅ 1 6 6 3 4 1 2 = 3 3 2 6 8 2 4 ⇒ 2 ( n − 2 ⌊ log 2 n ⌋ ) + 1 = 3 3 2 6 8 2 4 + 1 = 3 3 2 6 8 2 5
Hence at the end Person 3326825 will survive.