Finding which value I will be on after a certain number of steps I have a fixed array: [a,b,c], I wanna loop through this 3-items-sized array for 7 times in order to find what I would get at that exact step.
The &quot;value stack&quot; for 7 would look like a b c a b c a.
Question is, how can I find what value would be at step 10, for example?

Input: getValueForStep( [a,b,c], 7 )
Output: a
A simple observation is that, with 0-based indices:
final_index = (elements_traversed - 1) mod array_length

For example, for array_length = 3 and elements_traversed = 7, final_index = (7 - 1) mod 3 = 0 (corresponding to the first element).