It's my first time posting to the programming section, so here it is.
"There are people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom.
The task is to choose the place in the initial circle so that you are the last one remaining and so survive."
(quoted from Wikipedia: http://en.wikipedia.org/wiki/Josephus_problem)
in other words if you have n people ( numbered from 1 to n) the kth person is always eliminated until there is only one person after the first elimination the counting restarts from person numbered k+1 in the original circle ex: lets say we have 10 persons in a circle and we're eliminating the 4th starting anywhere ( its a circle after all) the elimination would go like this :
1 2 3 5 6 7 8 9 10
1 2 3 5 6 7 9 10
1 3 5 6 7 9 10
1 3 5 6 9 10
1 5 6 9 10
1 5 6 9
1 5 6
5 6
5
i solved it in java if you want me to post the solution tell me.
"There are people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom.
The task is to choose the place in the initial circle so that you are the last one remaining and so survive."
(quoted from Wikipedia: http://en.wikipedia.org/wiki/Josephus_problem)
in other words if you have n people ( numbered from 1 to n) the kth person is always eliminated until there is only one person after the first elimination the counting restarts from person numbered k+1 in the original circle ex: lets say we have 10 persons in a circle and we're eliminating the 4th starting anywhere ( its a circle after all) the elimination would go like this :
1 2 3 5 6 7 8 9 10
1 2 3 5 6 7 9 10
1 3 5 6 7 9 10
1 3 5 6 9 10
1 5 6 9 10
1 5 6 9
1 5 6
5 6
5
i solved it in java if you want me to post the solution tell me.