What to do when k > n

my code is not passing all test cases and I think it is because of k > n condition. So my question is what to do when K is greater than N.

Initially replace k with k%n. It will handle all the cases.