• + 3 comments

    % (modulus) gives you the remainder of division.so 4%5=4,5%5=0 likewise 6%5=1, it helps you to stay inside the limit i.e lesser than the value n (i.e till n-1) eg:if n=5 it goes from 0 to 4.try this simple mod in calc or put it in a loop you will understand.we are getting the input value to the rotated index thats why (-d).if right rotation +d.