Circular game survival
I want to play a game on a circular table; the rules of which are something like this.
(i) I will declare how many people are there initially which is say n.
(ii) I will declare the starting position
(iiI) I will declare k, which is the person i will keep killing till there is one survival.
Eg:: if n =6 and k=3 i will first kill 3rd person then 6th person and so on finally 1st will survive.
Now since you are the intelligent among the lot so i want you to come up with a formula which given k and n can help you figuring out a seat for yourself so that you will survive.
(i) I will declare how many people are there initially which is say n.
(ii) I will declare the starting position
(iiI) I will declare k, which is the person i will keep killing till there is one survival.
Eg:: if n =6 and k=3 i will first kill 3rd person then 6th person and so on finally 1st will survive.
Now since you are the intelligent among the lot so i want you to come up with a formula which given k and n can help you figuring out a seat for yourself so that you will survive.
f(n,k) = (f(n-1,k)+k))mod n with f(1,k) =0
ReplyDelete