“There are people standing in a circle waiting to be executed. After the first man is executed, certain number of people are skipped and one man is executed. Then again, people are skipped and a man is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last man remains, who is given freedom.
The task is to choose the place in the initial circle so that you survive (are the last one remaining).”
— Wikipedia, http://en.wikipedia.org/wiki/Josephus_problem
Assume that the number of people, P, in the circle may be any number between zero and one hundred.
Assume that every Nth person around the circle is killed each turn, where N is an integer between one and twenty.
There are several Java applet versions of this problem to check your work as you debug.