Modulo based counters
Sometimes we need counters that wrap around at certain intervals ex: 1,2,3,1,2,3,1,2,3 One way of doing this would be to increment our ‘counter’ and then reset it when it reaches our number int N = 3; int counter = 0; if (counter == N){ counter = 0; } counter++;int N = 3; int counter = …