1

The number that will keep increasing by X until its value is equal or more than Y and then it will be deducted by Y.
The result from that deduction will be used as the new start number of increment.

For example:
The starting number is 0. X = 7, Y = 20

time | result | count
-----|--------|--------
  1  |   0    |   0
  2  |   7    |   0
  3  |   14   |   0
  4  |   21   |   0
  5  |   1    |   1
  6  |   8    |   1
  7  |   15   |   1
  8  |   22   |   1
  9  |   2    |   2
 10  |   9    |   2
...

What is this called and are there any formula to calculate Count column?

1 Answers1

1

This is similar to the Bresenham line segment drawing algorithm on an integer lattice. (Also called a digital line.)

The general formula is

$$c_k=\left\lfloor \frac{kX}{X+Y-1}\right\rfloor$$

giving

$$0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 5 , 5 , 5 , 5 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 8 , 8 , 8 , 8 , 9 , 9 , 9 , 9 , \cdots$$