Concrete mathematics is Eulerian mathematics.
– Concrete Mathematics, Ronald L. Graham & Donald E. Knuth & Oren Patashnik
Problem
Josephus problem is a math puzzle with a grim description: n prisoners are standing on a circle, sequentially numbered from 0 to n-1.
An executioner walks along the circle, starting from prisoner 0, removing every kth prisoner and killing him.
As the process goes on, the circle becomes smaller and smaller, until only one prisoner remains, who is then freed.
Java
recurrence
1
1 | public static int josephus(int n, int k) { |
2
1 | public static int execute(int n, int k){ |
circular linked list
1 | static class Node { |