Getting run error

please explain, why this is happening.

hello @rabhi1611
value of k can be greater than n
so first do this->
k=k%n // to convert k less than n

and then call ur function if k!=0

ur updated code->