41 people stand in a circle, numbered 1 to 41 clockwise. The rule is the film's, stated exactly because the answer depends on it:
The counting never restarts. When someone is removed, the count carries on from the next person still standing. Play until one person is left. Which seat is that?
Picture a counter that sits on one person. The rule is: the person with the counter stays, the next person clockwise is removed, and the counter moves to the next person still standing. The counter starts on seat 1.
Everything that happens next depends only on the order of the people round the circle and on who holds the counter. So suppose some people have been removed and remain, with the counter on one of them. What follows is exactly the original game on people, with the people renamed clockwise starting from the counter. If the renamed survivor is , we only need to say which real seat is. That one idea gives everything below.
Let be the surviving seat for people. Clearly .
An even circle, . The counter is on seat 1, removes seat 2, moves to seat 3, removes seat 4, and so on. Seat is removed by the counter on seat . After seat goes, the counter passes to the next person standing, which is seat 1. One lap has removed every even seat and nothing else, and the counter is back on seat 1.
The people left are seats , with the counter on the first. Renamed from the counter, person is seat . By the idea above the rest is the game on people, so
An odd circle, with . The first removals are seats as before, and the counter then moves to seat . The count carries past the end of the circle, so the counter on seat removes the next person clockwise, which is seat 1. The counter moves to seat 3.
The people left are seats , with the counter on the first. Person is seat , so
Notice how the two cases differ. In the even circle seat 1 stays and becomes the first person. In the odd circle seat 1 is removed on the way round, and seat 3 becomes the first person.
The closed form, by strong induction on . Claim: if with , then .
Base case: is , and .
Step: take and assume the claim for every smaller number of people.
Either way the claim holds for , so it holds for every . Since is odd, the survivor is always an odd seat.
This is the film's picture of halving, and it needs no recurrence for the odd case.
A power of two. With people, seat 1 survives. Induct on . For there is one person. For one lap removes every even seat and returns the counter to seat 1, leaving people with seat 1 as the first. By hypothesis the first person survives, so seat 1 does.
Any number. Take people with . The first removals are seats , all in the first lap, since . The counter then stands on seat , which exists and has not yet been touched, because exactly when . Exactly people remain, and the counter is on one of them. That is the game on a power of two, where the person holding the counter survives. So the survivor is seat . This is the same answer, reached with no induction beyond the power of two.
Write with exactly binary digits , allowing leading zeros. Then is the digits
and is shifted one place left with a 1 in the units place:
That is the same string with its leading 1 moved to the end. It has digits too, and may start with a zero, which is simply dropped when you read it as a number.
Two special cases follow at once. A power of two is a single 1 followed by zeros, which rotates to , which is 1. And is all ones, which rotates to itself, so : the last seat. The converse holds as well. If then , so and is all ones. Likewise forces , so seat 1 survives only when is a power of two.
The halving chain in the film is this same fact seen one digit at a time. Taking to deletes its last binary digit, and the recurrences say that the last digit of decides which of and you want. A process that keeps halving a number is a process about its binary digits.
The film walks the recurrences down from 41, halving each time, until one person is left, then climbs back up. Each row uses the odd or even rule on the row below it.
| rule | working | ||
|---|---|---|---|
| 41 | odd | 19 | |
| 20 | even | 9 | |
| 10 | even | 5 | |
| 5 | odd | 3 | |
| 2 | even | 1 | |
| 1 | base case | 1 |
You can see the first step in the removals themselves. The first lap takes seats 2, 4, 6 and so on up to seat 40. The count then carries past seat 41 and takes seat 1. That leaves the odd seats from 3 to 41, which is the game on 20 people, renamed . Its survivor is person 9, which is seat .
By the closed form: , so . By the digits: 41 is 101001 in binary. Move the leading 1 to the end and you get 010011, which is 19.
| binary | rotated | ||
|---|---|---|---|
| 41 | 101001 | 010011 | 19 |
| 13 | 1101 | 1011 | 11 |
| 100 | 1100100 | 1001001 | 73 |
| 8 | 1000 | 0001 | 1 |
| 7 | 111 | 111 | 7 |
The last two rows are the special cases. 8 is a one and zeros, so the survivor is seat 1. 7 is all ones, so the survivor is seat 7, the last.
Here is for every from 1 to 16, written out by the recurrences. It falls back to 1 at the powers of two (1, 2, 4, 8, 16) and climbs by 2 in between.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 3 | 1 | 3 | 5 | 7 | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 1 |
The small cases the viewer is asked to do by hand are in it. For 5 people the removals go 2, 4, 1, 5 and seat 3 stands.
A million people. With 1,000,000 people, the largest power of two not above that is 524,288. So is 475,712, and the survivor is seat , which is 951,425. In binary the move is the same single one: 11110100001001000000 becomes 11101000010010000001. Nobody could simulate it by hand. The formula takes one subtraction.
A linear method that does not need binary. Number the seats from 0 and let be the survivor's number. After the first removal, which takes seat 1, the counter sits on seat 2, and people remain. Rename them from the counter: an old seat becomes modulo . So , with , and the survivor is seat . This runs in steps for any . The verifier uses it as an independent check on the binary rule.
Every third person, as in the old story. The same argument for "remove every -th person" gives . The doubling recurrences and the binary rotation belong to every second person only. The film uses every second.
Who goes first. The answer depends on the convention, which is why the film puts it on screen. If the counter started so that seat 1 were removed first, the circle would be the film's circle with every seat moved one place round. The survivor would be one seat earlier than (the last seat if is 1). The verifier checks only the film's convention, so this variant is argued here and not computed.
Round numbers. The film's dial stops at a hundred, a thousand and a million. The survivors the verifier records are 73 for 100 people, 977 for 1000 and 951,425 for 1,000,000.
scripts/josephus.mjs plays the circle out literally for every from 1 to 1999, removing people from a list one at a time. For each it asserts three things: the simulated survivor equals the binary rotation, equals , and is odd. It asserts that both recurrences hold for every in that range, and that seat 1 survives exactly at the powers of two. It also checks the table above, the spot values quoted in the film, and that the recorded kill order of each ring the film draws is a permutation of the seats that ends on the survivor. The 41 case is asserted to start with the even seats and then seat 1, and to leave seat 19.
The million is not simulated. The linear recurrence above runs for every up to 1,000,000. It is compared with the simulation at every up to 1999, and with the binary rotation at regular intervals and at the end. The script records 0 mismatches. A failure anywhere stops the build.
What is not checked by computation: the proof for all . The induction above does that, and the simulation tests it only up to 1999. The script does not check any convention other than the film's, or any rule other than every second person.
In binary 100 is 1100100. Move the leading 1 to the end to get 1001001, which is 73. The closed form agrees: take away the largest power of two not above 100, double what is left and add one.
We need , which means and so . These are the numbers whose binary digits are all ones, such as 7, for which the survivor is seat 7.
The closed form is , which is odd. In the game itself: is odd, and each recurrence turns the survivor of the smaller game into or , which is odd whatever is.
A lap now removes a third of the circle, not half, and unless is a multiple of 3 the lap ends part of the way through a trio, so where the next lap starts depends on the remainder. The tidy pair of doubling recurrences is gone, and with it the rotation of binary digits. The linear recurrence still works. The verifier does not test it.