Generalized formula to move in a circle

Правка en5, от hellomoto, 2020-10-22 20:45:09

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? So what will be the formula if we want to circle from ai to aj in an array(0 indexed and size of the array is n)?

Теги #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)