If I have an event that happens 15 times a second (numbered 1 - 15), but I only want to process it 3 times I can choose [1], [6] and [11],
. It's important that the events I process are as evenly spaced as possible and take into account wrap-around, i.e. the events are continuous 13, 14, 15, 1, 2, 3 etc.
If I want 4 items the best I can do is [1], [5], [9] & [13]
.
Is there a general algorithm that will calculate which events I need to process given the total number of events (total
) and the number to process (processAmount
).