A Java solution to the Josephus problem