# Why is the number of integers between $2$ integers not their difference? [duplicate]

Helping my kids in 3rd grade Math class today. We were rounding to the nearest $10$. So for $100$, the numbers that round to it are $95$ to $104$. $95, 96, 97, 98, 99, 100, 101, 102, 103, 104$ which are 10 numbers I asked how many numbers round to $100$ one kid says 9, I say 10.

Why is $104-95=9$ not the correct way to figure out the number of numbers?

What is the correct equation, if there is one?

## marked as duplicate by Matthew Towers, user21820, Arnaud D., Aqua, Ove AhlmanNov 16 '17 at 15:32

• en.wikipedia.org/wiki/Off-by-one_error – Wouter Nov 15 '17 at 17:26
• – G Tony Jacobs Nov 15 '17 at 17:27
• A fun sanity check you can do for a proposed equation: split an interval into many chunks and add up the sizes of the chunks. For example, cut the range 1-30 into the ranges 1-10, 11-20, and 21-30. Using the simple subtraction equation, the latter three chunks would each have 9 elements, for a total of 27 elements in the combination of the three chunks -- which clearly can't be right. The equations proposed below which add one do pass this sanity check -- that's not proof they're correct, but it is comforting evidence that they're on the right track! – Daniel Wagner Nov 15 '17 at 19:52
• My students know perfectly that if I assign as homework exercises from $95$ to $104$ page $239$ they must do TEN exercises, not nine. It's a question of "innumeracy". I highly recommend this book en.wikipedia.org/wiki/Innumeracy_(book) – Raffaele Nov 15 '17 at 20:06
• Is it possible that he thought that 100 doesn't round to 100 as it already is 100 and that he thought that rounding to 100 only applies to numbers not equal to 100? – DanielWainfleet Nov 15 '17 at 21:19

This is an example of the so-called fence post problem. It goes like this:

Suppose you are building a fence with rails suspended between fence posts. The fence might look like this: $$|=|=|=|=|=|$$ where $|$ denotes a post, and $=$ denotes a rail. If each rail is 10 feet long, how many posts do you need to make a fence 50 feet long?

The answer is that you need 6 posts. Why not 5? Because you need a post on both ends of the fence, so you always have one more post than you have rails.

The same idea applies to your situation. You want to count the number of integers that round to 100. This is all the integers between 95 and 104 (inclusive). The distance from 95 to 104 is 104-95=9. This is like building a fence 9 feet long with 1-foot long rails. The integers are the posts. How many posts do you need? You need one more post than you have rails, so 10 posts. There are 10 integers between 95 and 104 (inclusive). The equation to use is $$\text{# of integers between a and b (inclusive)}=b-a+1.$$

• Is it worth commenting that if you define your range by "lowest value in the range" and "lowest value not in the range", (a half-open range) then you can calculate the size of the range by subtracting the two limits. That is why a lot of computer programmers have moved to such a definition over the last 20 years. – Martin Bonner Nov 16 '17 at 11:29
• am I being too technical for wanting a statement like posts have no length? – Ev. Kounis Nov 16 '17 at 12:07

A difference $a-b$ measures the amount of gaps between the numbers $a$ and $b$, and there is always one gap less than numbers surrounding it.

$\qquad\qquad\qquad\qquad\qquad\qquad$

This is because you can associate every gap to the number from which it starts, but there must always be another number at the end. No gap starts there.

This means a number sequence starting from $a$ and ending in $b$ contains $a-b\color{red}{+1}$ numbers.

Making steps

Think about making steps. When you made five steps, you left six footprints because there is also one in the place where you started.

$\qquad\qquad\qquad\qquad\qquad\qquad$

• +1 for steps. This is what I tell my students who make this error. – Alfred Yerger Nov 16 '17 at 2:18

If you want to count all of the integers from $95$ to $104$, then you want to take the integers from $1$ to $104$, and then exclude those from $1$ to $94$. Thus $104-94=10$. If you subtract $95$, then you're excluding everything up to $95$.

This is called the fencepost problem. See this reference for a detailed treatment.

Ask this trivial question: how many numbers are there from 1 to 1? Even though the difference is 0, we do have one number that satisfies the question. Therefore you always need to add one to the difference to get the correct number.

• I find this particular answer a bit unsatisfying. I guess my main complaint being the "therefore you always need to do X" bit -- all we've actually learned is that "when computing the size of the range 1 to 1 with such-and-such a method, we need to add one". But there's no real reason to believe that "such-and-such a method" is a good one, or that the error on other ranges is also 1. I know a fully formal proof is completely inappropriate for this question, but this explanation just feels like it loses too much power to convince in its attempt to be widely accessible. – Daniel Wagner Nov 15 '17 at 18:12
• @DanielWagner: I did not want to add formal proof as the previous answers cover the subject in enough details, this was an attempt to show that the simple difference between boundaries will not give the correct result. Of course, the follow up question would be how many numbers are there from 1 to 2, and we can prove formula using induction. – Vasya Nov 15 '17 at 18:26
• I think a more complete answer in this vein would also discuss the amount of numbers between 1 and 2. Is it 1? Or is it still 0? If it's 1, then they are counting the lengths between the numbers. If it's 0, then they are counting the 'joining' numbers between differing lengths. Alternatively, are they 'counting' one of the ends? This results in the same number as counting the 'lengths', but can be thought of in a different way. – Nate Diamond Nov 15 '17 at 23:09

With respect to fencepost, which is my first choice.

The ticket seller - You are selling tickets to a ride, they are \$10 each, and the roll of tickets starts with #95. After 30 minutes, you need to go to the restroom (you should have gone before the shift started?) and the manager runs over to review your cash. Tickets #95 - #104 are missing, how much cash do you expect the manager to count? \$100 105-114 would be the next 10 tickets. By subtracting, you miss the first ticket.

If the student doesn't see this easily, I jump to this - You sold tickets number 1 thru 10. How many tickets did you sell? 9? No, 10, the tickets did the counting. So 11-20 is another ten, not "20-11=9"