Josephus problem in java