Finish Prime Ring Problem

Finish Prime Ring Problem with harder solution, need better and simpler
solution for search the anticlockwise or clockwise