Home > Mathematica, Mathematics > Josephus

## Josephus

I was motivated after the locker puzzle to think about the Josephus   problem.

According to wikipedia:

The problem is named after Flavius Josephus, a Jewish historian living in the 1 st century.According to Josephus’ account of the siege of Yodfat, he and his 40 comrade soldiers were trapped in a cave, the exit of which was blocked by Romans.They chose suicide over capture and decided that they would form a circle and start killing themselves using a step of three.Josephus states that by luck or maybe by the hand of God (modern scholars point out that Josephus was a well educated scholar and predicted the outcome), he and another man remained the last and gave up to the Romans.

Wolfram MathWorld provides useful information.

Using recursive dropping of list elements I was able to implement a solution to the problem. The Wikipedia entry explores the recursive functions for the special case of every second man and then lists the general recursive formula.

For the classic problem (41 people, kill every 3rd person)  the following animation, reveals the last man standing is number 31 and the last pair 16, 31. Those killed at each round are rendered red.

The following are  tables for for the 2 and 3 step problems.