There are N people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people K are skipped and the next person is executed. The elimination proceeds around the circle, which is shrinking in size, until only the last person remains. Find the position of the last person.
{
"n": 5,
"k": 2
}3{
"n": 7,
"k": 3
}4{
"n": 41,
"k": 2
}19Sign in to Run Code and Submit