The Josephus Problem: Exercise 3.11
- The survives? procedure is partially written for you on page
66. Complete it so that it uses iteration to determine whether a
given position survives the slaughter.
- The iterative step should use the renumber procedure from the
previous exercise.
- Test your survives? using n = 8 and by calling it on
all 8 positions. Only positions 4 and 7
should survive.
- If you want, you can solve the 40-person Josephus Problem now by
using n = 40 and by calling survives? on all
40 positions (only 13 and 28 should survive).
But the next exercise produces a procedure that does this for you.