Count multiples of 7 between range using positioning I am interested in finding the number of multiples of $7$ between $[10, 500]$
In other cases I have seen that a neat trick is to check if there is a pattern between the sequence of numbers and their corresponding position (e.g. for multiples of $3$ the position is $1/3$ of the number and hence it is easy to figure out the last position hence total numbers).
For this case I tried to follow this same process:




14
21
28
35
42
49
........
490
497




1
2
3
4
5
6
........

?




but I could not find any relation between the numbers in the upper row and the numbers in the lower row so as to deduce the last number in the lower row and figure out the number of multiples.
Is it possible to apply this in this case? Am I missing a pattern?
 A: HINT: Separate the interval into subintervals of length $7$. How many multiples of $7$ are there in each of them?

On the other side, the pattern in the sequence is $7(n+1)$ for $n \le 70$. We use $n+1$ instead of $n$, as we need to shift since $7 < 10 < 2 \times 7$. Also we need $n \le 71$, since $71 \times 7 < 500 < 72 \times 7$.
A: It is probably possible to spot some kind of pattern, but it is simpler to solve the question directly. The first multiple of $7$ in the interval is $14$, and the last one is $497$. Hence, there are
$$
\frac{497-14}{7}+1=70
$$
multiples of $7$ in the interval.
If you're curious as to why we have to add $1$ to get the final answer, then please consult this Wikipedia article. Let me know if you have any questions.
A: Assume that $a,b \in \Bbb{Z^+}, ~a < b.$
Assume that you want to know how many multiples $m$ of $(7)$ there are such that $a \leq m \leq b.$
For $k \in \Bbb{Z^+}$, let $f(k)$ denote the unique integer $r \in \{0,1,2,\cdots,6\}$ such that $7 ~| ~(k - r).$
That is, $f(k)$ represents the smallest non-negative residue of $k, \pmod{7}.$
For $r \in \Bbb{R}$, let $\lfloor r\rfloor$ represent the largest integer that is $\leq r ~$ (i.e. the floor of $r$).
$\underline{\text{Case 1:} ~f(a) > f(b)}$
Computation is
$\displaystyle ~1 ~+ ~\left\lfloor \frac{b - a}{7}\right\rfloor.$
For example $(a,b) = (10,16)$.
$\underline{\text{Case 2:} ~f(a) = f(b) = 0}$
Computation is
$\displaystyle ~1 ~+ ~\left\lfloor \frac{b - a}{7}\right\rfloor ~~=~~ ~1 ~+ ~\frac{b - a}{7}.$
For example $(a,b) = (7,14)$.
$\underline{\text{Case 3:} ~f(a) = f(b) \neq 0}$
Computation is
$\displaystyle \left\lfloor \frac{b - a}{7}\right\rfloor ~~=~~ \frac{b - a}{7}.$
For example $(a,b) = (8,15)$.
$\underline{\text{Case 4:} ~0 = f(a) < f(b)}$
Computation is
$\displaystyle  ~1 ~+ ~\left\lfloor \frac{b - a}{7}\right\rfloor.$
For example $(a,b) = (7,16)$.
$\underline{\text{Case 5:} ~0 < f(a) < f(b)}$
Computation is
$\displaystyle \left\lfloor \frac{b - a}{7}\right\rfloor.$
For example $(a,b) = (8,16)$.

I separated the situations into 5 cases, for illustrative purposes.  You can certainly collapse Cases 2 and 4.  Also, you can collapse Cases 3 and 5.
