Josephus Problem

The Problem:

People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only one person remains, and is freed. The problem — given the number of people, starting point, direction, and number to be skipped — is to choose the position in the initial circle to avoid execution. (Wikipedia)
If you want to hear more about a specific variation of the problem, watch this Numberphile video. Stop at around 50 seconds if you want to figure it out yourself!
Here's an applet that lets you change up the number of people and the number of people skipped each turn:
If you want to learn more about the problem... and some of the math behind it, check out its Wikipedia page:

A function for the case when the next living person is killed...