Logic puzzles and brainteasers entertain and intrigue us. But there've been instances where getting those puzzles right meant the difference between life or death.

The most famous of these problems is the Josephus problem.

The Josephus problem (or permutation) relates to counting out spaces strategically. The story goes that Jewish historian Flavius Josephus and his men were captured in battle. Rather than surrender to the opposition, they decided to execute one another systematically with the last man standing vowing to commit suicide. Historical rumors say Josephus became that last man standing; however, he decided to beg for capture rather than die.

Did Josephus manage to be the last man standing with only sheer luck? Or is there a strategy?

The first round is easily survivable, as person number 1 kills 2, 3 kills 4, and so on until the even numbered positions have been removed. But then things get a bit trickier.

Josephus had 41 soldiers with him, and there was no time to work through each scenario in his head. What's the math behind it?

Check out the above video featuring Daniel Erman from the University of Wisconsin - Madison as he explains exactly how the Jewish historian stayed alive.

[Image Courtesy of *YouTube*]

In short, the best place to stand if you find yourself in a Josephus situation is the first position when the number of people in the circle is a power of 2.

However, the math gets a bit trickier with other sized groups. Each number between the powers of two increases by two positions. For example, the winning spot for a group of 4 people is Spot 1. For 5 people, it's Spot 3. For 6 people, it's Spot 7. This continues until the group size "resets" with the next power of 2.

[Image Courtesy of *YouTube*]

If you want to skip ahead to the binary bits, start the video at 7:50.

### SEE ALSO: This Insanely Complex Tree Logic Puzzle Will Give You a Run for Your Money

We hope you never find yourself in a real-life Josephus situation, but if for some reason you do, you'll be prepared.

Via Numberphile