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

Правка en6, от hellomoto, 2020-10-22 20:46:37

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 (0 <= i, j < 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 (0 <= i, j < n) in an array (0 indexed and size of the array is n)?

Any help will be appreciated.

Теги #math

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en6 Английский hellomoto 2020-10-22 20:46:37 190
en5 Английский hellomoto 2020-10-22 20:45:09 190 Reverted to en1
en4 Английский hellomoto 2020-10-22 20:40:51 172
en3 Английский hellomoto 2020-10-22 20:36:25 10
en2 Английский hellomoto 2020-10-22 17:28:44 8
en1 Английский hellomoto 2020-10-22 17:12:58 413 Initial revision (published)