Josephus problem - linked lists