Hi,
A quick warning: be careful when making assumptions that dividing by N will necessarily give you the right number of multiples of N.
If we are talking about 20 consecutive integers, it is possible that the list will contain 6 multiples of 3:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
The multiples of 3 are 3, 6, 9, 12, 15, 18
It is ALSO possible that a list of 20 consecutive integers will contain 7 multiples of 3:
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
The multiples of 3 are 3, 6, 9, 12, 15, 18, 21
Instead, make sure that you take note of the SMALLEST and LARGEST multiple of N in the list. This is the key to finding the answer.
In the first example above, the smallest and largest multiples of 3 are: 3 and 18. In the second example above, the smallest and largest multiples of 3 are: 3 and 21.
To find the number of multiples of N in a certain range, first find the SMALLEST and LARGEST multiple of N in the list. Call these A and B.
The number of multiples of N is (B - A)/N + 1.
In the first example above, (B - A)/N + 1 = (18 - 3)/3 + 1 = 5 + 1 = 6.
In the second example above, (B - A)/N + 1 = (21 - 3)/3 + 1 = 6 + 1 = 7.
As another example, think about the multiples of 5 between 6 and 19, inclusive. Then, think about the multiples of 5 between 9 and 16, inclusive. In each case, the answer is 2 (10, 15).
If we just used the differences of the first and last number, we would get:
(19-6)/5 = 2.6
(16-9)/5 = 1.4
This is misleading, since the answer in each case is 2.
If instead we use the formula above, in each case we will find that A = 10, B = 15, and (B - A)/N + 1 = (15 - 10)/5 + 1 = 1 + 1 = 2, which is correct.
Since the question in the initial post asks about 21 consecutive integers, we get a bit lucky, in that any string of 21 consecutive integers has seven multiples of 3.