Here’s a classic maths retold: 1,024 pirates stand shoulder to shoulder in a circle, numbered 1 through 1,024. On the captain’s whistle, the 1st pirate shoots the 2nd, the 3rd shoots the 4th, and so on around the ring — every shooter spares the one beside them and fells the one just past.
The fallen are dragged from the circle, but the ring closes up and the shooting continues, always the standing pirate taking aim at the next standing pirate, round after round, until a single pirate remains.
The question is: Where in the circle would you stand to be the one left holding the pistol?
Once again, this is a good moment to pause the article and give the problem a go yourself. When you’re ready, keep reading for the solution. And if you come up with your own approach, feel free to share it in the comments — I’d love to see how you tackled it.
Don’t forget to subscribe to our YouTube channel for more maths puzzles, it’s my goal to reach 100k subscribers someday.
Solution
First off, here’s an intuitive explanation.
Every complete round removes exactly half of the pirates. When the number of pirates is a power of two, the survivor keeps getting mapped back to the first position after each relabelling:

Each reduction preserves the identity of the first pirate, so the original Pirate 1 survives all the way to the end.
Now try the following visualisation on Claude.


Now for a more mathematical explanation:
Let J(n) denote the winning position (counting from 1) when every second person is eliminated.
Here, n = 1024.
Observe the first round:
Initially:
- Pirate 1 shoots 2
- Pirate 3 shoots 4
- Pirate 5 shoots 6
- …
After the first round, only the odd-numbered pirates remain:
1, 3, 5, …, 1023
There are now 1024/2 = 512 pirates left.
Here’s the trick, we can relabel
1, 3, 5, …, 1023
as
1, 2, 3, …, 512
This means the game is exactly the same as before, only with 512 pirates.
So now we have the following formula to start with

Remember that J(n) denotes the winning position (counting from 1) when every second person is eliminated.
Now pirate 1 gets relabelled as pirate 1. This checks out because 1 = 2(1) – 1.
Similarly pirate 3 gets relabelled as pirate 2. Again it checks out because 3 = 2(2) – 1.
Hopefully you understand where the formula comes from.
In fact we can keep iterating this formula:

Now what is J(1)? It means the winning position of the player when there’s only one player left. And who would that be? Well of course the 1st pirate himself!
So we obtain

Remember the question asked us the winning position when there are 1024 players in the game.
So we can substitute J(1) = 1 into our original formula

This means the first pirate is the last man standing. I guess, just be first reigns true, both in romance and at sea. Ahoy!

Some Trivia
- This problem is called “Josephus problem”, named after Flavius Josephus, a Jewish historian living in the 1st century. Allegedly, he and his 40 soldiers were trapped in a cave by Roman soldiers. Preferring suicide instead of being captured, they decided to form a circle and, kill every third soldier until none remained. Josephus, who preferred to surrender, managed to arrange the order of the soldiers in the circle so that he and another man were the last two survivors. At this point, they surrendered to the Romans rather than killing themselves.
- The General Formula: If n is not a power of 2, there is a simple formula for finding the safe position. First, find the largest power of 2 that is less than or equal to n. Next, calculate: l = n − 2^m where 2^m is the largest power of 2 less than or equal to n. The safe position is then: Safe position = 2l + 1 Suppose there are 100 pirates. The largest power of 2 less than or equal to 100 is: 2^6 = 64 So, l = 100 − 64 = 36 Finally, Safe position = 2 × 36 + 1 = 73 Therefore, the pirate standing in position 73 is guaranteed to survive. If you’re interested in the mathematical proof of why this formula works, you can find a detailed explanation on the Wikipedia page for the Josephus problem.
And that’s our answer. How amazing. Hey, don’t forget to clap👏 the article as a token of appreciation. Thank you 🦁




Leave a Reply