https://en.wikipedia.org/wiki/Josephus_problem

Sorry, I obviously have made my question unlike Josephus here while I did not mean it. So I correct it below.

You have a circle of n apples, and you first eat 0 apple(no apple), and you skip k - 1 apples and eat the kth apple, so on so forth until there is only one apple. If the apple does not want to be eaten, which position should it be at the beginning.

Eg, if there is one apple, the apple just needs to be at position 1. If there are 10 apples, the apple needs to be at position 5 if k = 2.

```
def josephus(n, k):
if n == 1:
return 1
return (josephus(n - 1, k) + k - 1) % n + 1
def josephus2(n):
power = 1
while power * 2 <= n:
power *= 2
return (n - power) * 2 + 1
```