Josephus Problem

josephus( n, k):
if n ==1:
return 1
else:
return ((josephus(n-1,k)+k-1) % n)+1

I am somewhat stuck up with this recursive solution… how come we are able to arrive at the final answer using this code… I have had a dry run it works good but I am not able to design the logic behind this code. In addition, what is the +k-1 part used for?

Do you understand [this][1]?