The Josephus problem is a classic numberphile problem around mathematics and combinatorics.
It goes like this:
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.
For n = 5 and k = 2, simulation will look like this
[1*, 2, 3, 4, 5]
[1, 3*, 4, 5], dead = 
[1*, 3, 4 ], dead = [2, 5]
[1*, 3], dead = [2, 5, 4]
The general version of this problem can be solved using recursion.
Following is a good article that explains how we derive the recurrence relation in a simpler manner.
Recurrence relation for the Josephus problem is denoted by:
f(n, k) = (f(n-1, k) + k-1)%n + 1