Data structure circular linked list solves Joseph problem (C++ implementation