Calculating the number of integers divisible by 8 Given the set [10000,70000], in order to calculate the number of terms divisible by 8 I know of two ways to calculate the answer
1st is
$$\frac{70000-10000}{8}+1=7501$$
2nd is
$$⌊\frac{60001}{8}⌋=7500$$
the fact that the results differ is very peculiar to me, can anyone explain what is going on, and which one is more accurate?
 A: The problem is that both endpoints of the interval $[10000, 70000]$ are divisible by $8$, while neither endpoint of the interval $[1, 60001]$ is divisible by $8$.
Your first method is correct.  It works since both endpoints are divisible by $8$.
In your second method, your interval should start at $0$ and end at $60,000$ so that both endpoints are again divisible by $8$.  You then have to add $1$ to account for the fact that $0$ is divisible by $8$.  Observe that
$$\left\lfloor \frac{60000 - 0}{8} \right\rfloor + 1 = 7501$$
A: If you want a catch-all formula for the number of multiples of $n>0$ in $[a,b]$, you may use $$\left\lfloor \frac bn\right\rfloor-\left\lceil\frac an\right\rceil+1,$$
which essentially comes from the consideration that the map $x\mapsto nx$ defined on the integers in $\left[\left\lceil\frac an\right\rceil,\,\left\lfloor \frac bn\right\rfloor\right]$ is bijective onto the set of multiples of $n$ in $[a,b]$. In a number of instances the nuance of where to divide and where to take floor or ceiling is obscured by other facts.
A: Your second method, generalized to the interval $[a,b],$ appears to be
$$\left\lfloor \frac{b - a + 1}8\right\rfloor.$$
The floor function gives you an integer, which you want, but it does this
simply by throwing out any fractional part.
When you use a formula like
$$\left\lfloor \frac x8\right\rfloor,$$
you get zero for the first seven positive values of $x$.
You don't get a positive result until $x \geq 8.$
Consider the simpler problem of counting multiples of $8$ in the set
$[10000, 10000].$ There is one element in that set and it is a multiple of $8$,
so the answer should be $1,$ but
$$\left\lfloor \frac{10000 - 10000 + 1}8\right\rfloor
= \left\lfloor \frac 18\right\rfloor = 0.$$
You'll get the same wrong answer for $[10000,10001],$ $[10000,10002],$ $[10000,10003],$ $[10000,10004],$ $[10000,10005],$ and  $[10000,10006].$
For $[10000,10007],$ you get
$$\left\lfloor \frac{10007- 10000 + 1}8\right\rfloor
= \left\lfloor \frac 88\right\rfloor = 1,$$
which is finally a correct answer.
But for $[10000,10008]$ you still get only $1$ from the formula while the correct answer is $2.$
The problem is that your formula only counts every eighth integer, but your interval has a multiple of $8$ at the first integer.
The only time the formula is correct is just before you reach the next multiple of $8,$ because that's the only time you can partition the set of integers into subsets with exactly $8$ integers in each subset and exactly one multiple of $8$ in each subset.
If your set started at $10001$ instead of $10000$ the formula would work fine, because the first seven integers starting at $10001$ are not divisible by $8$ and you only get a multiple of $8$ at the eighth integer added to the set.
The catch is that in general, in order to know how many multiples of some integer $n$ are in a set of consecutive integers it is not enough to know how many integers are in the set. The only time this information is sufficient is when the number of integers is an exact multiple of $n$. In any other case you need to know where the sequence starts (at least relative to the nearby multiples of $n$) in order to know whether there is an "extra" multiple of $n$ in the numbers that are left over after you have partitioned the rest of the numbers into subsequences of $n$ numbers each.
A: Hint: This is where those "flooring methods" came from:
$$10,000 \le 8k \le 70,000 \\[1mm] \frac{10,000}{8} \le k \le \frac{70,000}{8} \\[1mm] \\ 1250 \le k \le 8750 $$
Now, just count how many natural numbers there are between $1250$ and $8750$; that is, $8750 - 1249 = 7501$.

Since, the ratios above might not be integer in general, we can sharpen the bounds
$$\left\lceil\frac{10,000}{8}\right\rceil \le k \le \left\lfloor\frac{70,000}{8}\right\rfloor $$ which shows that your first approach is right.
