There is a much easier way to solve the Josephus Flavius puzzle than any of the webpages.Note:
This solution references the starting position of the circle as 0!
If x is the increment and n is the total number of people, then the position on the circle is given by this formula:
-(x^(m+1)) (mod n), where m is the largest integer st x^m <= n
or alternatively
-(x^m) (mod n), where m is the smallest integer st x^m >= n
Explanation:
The position is always 0 whenever n is a power of x. This is because in the first pass around the circle all y*x positions are eliminated, second pass all y*(x-1) positions are eliminated, etc until y*(x-x) = 0 is the only position left.
If n is not a power of x, then using x^m as a starting point, where m is the largest integer st x^m < n, the position increments by x for however much n is in excess of x^m. A direct computation results in (n - x^m)*x. To prevent wraparound references (ex: the 18th position of a 13 person circle) the answer must be computed mod n. This results in:
(n - x^m)*x (mod n) = (n*x - x^(m+1)) (mod n) = -(x^(m+1)) (mod n)