How to generalized formula to move x steps in a circle?

Revision en4, by hellomoto, 2020-10-22 20:40:51

As we know if we have an array of size n, let's say a0, a1, a2, ......, an-1. we can preform x move clockwise with ((ai + x) % n) and anticlockwise with ((ai — x) % n + n) % n.

Can we generalized for clockwise and anticlockwise for the index i to j (i >=0 & i < n)?

So what will be the formula if we want to move x (x can be greater than (j — i + 1)) steps in a circle from ai to aj (i >=0 & i < n) in an array (0 indexed and size of the array is n)?

Any help will be appreciated.

Tags #math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English hellomoto 2020-10-22 20:46:37 190
en5 English hellomoto 2020-10-22 20:45:09 190 Reverted to en1
en4 English hellomoto 2020-10-22 20:40:51 172
en3 English hellomoto 2020-10-22 20:36:25 10
en2 English hellomoto 2020-10-22 17:28:44 8
en1 English hellomoto 2020-10-22 17:12:58 413 Initial revision (published)