42
$\begingroup$

Here's an example question from the SAT question of the day:

On the last day of a one-week sale, customers numbered 149 through 201 were waited on. How many customers were waited on that day? Possible answers: 51, 52, 53, 152, 153.

The correct answer here is 53, which is the result of (201-149) + 1 = 53.

What's the reasoning in adding the +1?

$\endgroup$
8
  • 10
    $\begingroup$ Consider the case in which customers 0-1 were waited on. 1-0 = 1, because you're "not counting" one of the ends. 1-0 + 1 = 2, the correct answer. $\endgroup$ Sep 4, 2013 at 23:06
  • 13
    $\begingroup$ Use smaller numbers. How many numbers are there from $7$ to $10$ inclusive? There are $4$, you can list them. This is $1$ more than $10-7$. $\endgroup$ Sep 4, 2013 at 23:07
  • 16
    $\begingroup$ Because if you don't add 1, you are left with 52, which is not the correct answer. $\endgroup$
    – Kaz
    Sep 5, 2013 at 4:10
  • 13
    $\begingroup$ In my country, we learn this at elementary school. $\endgroup$
    – sawa
    Sep 5, 2013 at 6:52
  • 25
    $\begingroup$ It's sad to see "add 1 to counting test problems" being taught as one of those "rules"... $\endgroup$
    – ithisa
    Sep 5, 2013 at 13:49

16 Answers 16

95
$\begingroup$

If you don't add 1, then you're saying "take the first 201 customers, but then exclude the first 149 ones." That would give you the number of customers in the list from 150-201.

The way I think of it is this: The number of customers from #149 to #201 is $201-148=53$, because it's the first 148 customers we're trying to exclude.

Does that help?

$\endgroup$
5
  • 25
    $\begingroup$ I'd like to add that this is one of the reasons that in programming we almost exclusively work with up to exclusive bounds. $\endgroup$
    – orlp
    Sep 5, 2013 at 2:51
  • 7
    $\begingroup$ (And down to inclusive - AKA half-open intervals) $\endgroup$ Sep 5, 2013 at 10:40
  • 12
    $\begingroup$ @nightcracker Also the reason why most programming languages start indices from 0 and why programming languages indexing from 1 are so terrible to use. $\endgroup$
    – Sulthan
    Sep 5, 2013 at 10:41
  • 5
    $\begingroup$ @Sulthan and why "Foreach" constructs are normally a godsend. $\endgroup$
    – WernerCD
    Sep 5, 2013 at 16:06
  • $\begingroup$ @orlp Wait, are you saying that programming languages use [first, last) bounds as a syntactic aid so programmers can do a quick mental calculation when they read it an statement? I.e. When you see a function with parameters like (int startIndex, int endIndex), you know immediately that the number of elements considered in this range is equal to (endIndex-startIndex). I thought this was more a consequence of how architectures define word/memory address sizes. $\endgroup$ Mar 12, 2021 at 9:55
46
$\begingroup$

There's a Wikipedia article about this question:

http://en.wikipedia.org/wiki/Off-by-one_error#Fencepost_error

$\endgroup$
1
  • 5
    $\begingroup$ I first noticed this phenomenon in elementary school, where the baseball field's backstop had three sections of netting between four poles. I never knew this idea actually had a name, and was related to fences. $\endgroup$
    – cobaltduck
    Sep 5, 2013 at 11:16
25
$\begingroup$

Here's one way of thinking about it.

The numbering of customers is pretty inconvenient. It would be much better if the first customer was customer number $1$, the second customer was customer number $2$, and so on. That way, the total number of customers would be the customer number of the last customer. So I am going to change the numbering of customers to suit my needs. How am I going to do this? Well, to change the first customer's number from $149$ to $1$, I subtract $148$. Likewise, for each customer, their new customer number is their old one minus $148$. This gives the desired numbering and the final customer's new customer number is $201 - 148 = 53$. Therefore $53$ people were waited on.

Note $201 - 148 = 201 - (149 - 1) = 201 - 149 + 1$; that's where the one comes from. If you didn't add the one, the first customer's number would be zero, not one.

$\endgroup$
12
$\begingroup$

Look at an example at a smaller scale, say we have three people: $$1,2,3$$

Then $$3-1=2$$

is the number of commas, but there is one more person than commas.

You can see that adding another number $$1,2,3,4$$ adds both another person and another commas and so this difference of one remains.

This gap was created with the first person $$1$$

there is $0$ commas but one person.

$\endgroup$
2
  • $\begingroup$ I find the explanation using gaps the most interesting :) $\endgroup$
    – Prism
    Sep 5, 2013 at 23:29
  • $\begingroup$ @Prism - it's nice to hear that, thanks :) $\endgroup$
    – Belgi
    Sep 5, 2013 at 23:40
10
$\begingroup$

A.) In sets:
| (149 , 201] | = 52
| [149 , 201] | = 53

B.) Using a property of summation,
if we shift the index of expression below so that $\left(n=149\right)$ will become $\left(n=1\right)$ $$\begin{align} Y & = \sum_{n=149}^{201}{n} \\ & = \sum_{n=149-148}^{201-148}{n+148} \\ & = \sum_{n=1}^{53}{n+148} \end{align} $$

The upper bound is 53.


C.) Counting the customers from 149th to 201:

1.) 149th customer
2.) 150th customer
3.) 151st customer
4.) 152nd customer
5.) 153rd customer
6.) 154th customer
7.) 155th customer
8.) 156th customer
9.) 157th customer
10.) 158th customer
11.) 159th customer
12.) 160th customer
13.) 161st customer
14.) 162nd customer
15.) 163rd customer
16.) 164th customer
17.) 165th customer
18.) 166th customer
19.) 167th customer
20.) 168th customer
21.) 169th customer
22.) 170th customer
23.) 171st customer
24.) 172nd customer
25.) 173rd customer
26.) 174th customer
27.) 175th customer
28.) 176th customer
29.) 177th customer
30.) 178th customer
31.) 179th customer
32.) 180th customer
33.) 181st customer
34.) 182nd customer
35.) 183rd customer
36.) 184th customer
37.) 185th customer
38.) 186th customer
39.) 187th customer
40.) 188th customer
41.) 189th customer
42.) 190th customer
43.) 191st customer
44.) 192nd customer
45.) 193rd customer
46.) 194th customer
47.) 195th customer
48.) 196th customer
49.) 197th customer
50.) 198th customer
51.) 199th customer
52.) 200th customer
53.) 201st customer

They are all 53 :)

$\endgroup$
0
9
$\begingroup$

Hold up your hand with your fingers splayed. The subtraction 201 - 149 counts the gaps between the customers, just as calculating 5 - 1 counts the gaps between your fingers.

To count the customers you must then add 1, just as to get the correct finger count you must add 1 to the result of 5 - 1..

$\endgroup$
6
$\begingroup$

With diagram

enter image description here

With algebra

Arithmetic sequence has a relation as follows,

$$a_n=a_1+d(n-1)$$

where:

  1. $a_n$ is the $n$th item.
  2. $a_1$ is the first item.
  3. $d$ is the difference between two consecutive items.

In your case, the sequence has $d=1$. Applying this to the equation above, we have,

\begin{gather} a_n =a_1 + 1\times (n-1)\\ a_n=a_1 + n-1\\ n=a_n-a_1+1 \end{gather}

$\endgroup$
1
  • $\begingroup$ Thanks for this idea of linking the summation formula of arithmetic sequences to the act of "counting". This is quite memorable! $\endgroup$ Jun 7, 2020 at 7:55
2
$\begingroup$

This is trivial to explain by using some small numbers.

On the last day of a one-week sale, customers numbered 1 through 2 were waited on. How many customers were waited on that day?

We know that customers 1 and 2 were waited on. That's 2. Without the +1, your answer is 2 - 1 = 1. Wrong! This equation excludes the first person (customer #1). We need the plus one to include the first person.

We can even make it simpler:

On the last day of a one-week sale, customers numbered 1 through 1 were waited on. How many customers were waited on that day?

The right answer is obviously 1. But 1 - 1 = 0. Again, we need the +1 to include the first (and only) person.

$\endgroup$
2
$\begingroup$

I'm sure several of these answers are technically 'more' correct but, really, this is very simple. The calculation 201-149 will not include customer 149. You want to include customer 149 in your count so what you really want is to subtract the last numbered customer which is not in your included customers from the total. Questions like this are designed to show us that it is very easy to forget zero when counting items.

$\endgroup$
1
$\begingroup$

To prove: there are M - N + 1 customers in the numbered range M through N.

Firstly, in the range 1 to M, there are M customers, and similarly in the range 1 to N, there are N customers. This is because the numbering follows simple enumeration: customers are assigned the natural numbers, and thereby they are counted, meaning that the number assigned to the last customer in the range also represents the count of the customers.

Now when we consider the range M through N, there are two cases: M = 1 and M > 1.

If M = 1, then the range M through N is just 1 through N, and so there are N customers. In this case, M - N + 1 is 1 - N + 1 whose terms can be rearranged to N + 1 - 1 and canceled down to N, confirming that the formula to be proven works for this case.

If M > 1, then we can consider the range M through N as if it were the range 1 through N, but with the customers from 1 to M-1 removed. There are M - 1 customers in the range 1 through M - 1. These must be subtracted from the N customers in the range 1 through N, hence the count is N - (M - 1).

But the formula N - (M - 1) is equal to N + -1(M - 1) which reduces to N - M + 1 when we distribute the -1 factor into the binomial (M - 1).

$\endgroup$
1
$\begingroup$

Let $C_n$ be the customer numbered $n$. List the customers in question:

$$C_{149},C_{150},C_{151},\ldots,C_{200},C_{201}\;.$$

Now write their numbers in the form $148+\text{something}$:

$$C_{148+\underline1},C_{148+\underline2},C_{148+\underline3},\ldots,C_{148+\underline{52}},C_{148+\underline{53}}\;.$$

In this form it’s clear that if you ignore the $148$, you’re just counting from $1$ through $53$, so there are $53$ customers. Now think back to see where the $53$ came from: it was what had to be added to the base-point $148$ to get $201$, the last customer number, so it was $201-148$.

A little thought will show you that the same idea works in general, and that the base-point number will always be that of the last customer not being counted, so it will be one less than the number of the first customer that you want to count. If you’re counting the customers from $C_{\text{first}}$ through $C_{\text{last}}$, your base-point number will be $\text{base}=\text{first}-1$, and your counted customers will be

$$C_{\text{base}+1},C_{\text{base}+2},C_{\text{base}+3},\ldots,C_{\text{base}+?}\;,$$

where $\text{base}+?=\text{last}$. Thus, the question mark must be

$$?=\text{last}-\text{base}=\text{last}-(\text{first}-1)=\text{last}-\text{first}+1\;.$$

$\endgroup$
1
$\begingroup$

Always take in mind that subtracting number $b$ from $a$ means that how much should be added to $b$ to reach a?
Therefore, there is an obvious different between subtraction and counting. Your problem is about counting from 149 to 201, so that you must include 149 in your counting (but subtraction exclude 149 [see the italic sentence at the first line!] and it is the reason to add +1). Subtraction means that How many numbers (or distance -Real nubmers case) are between two numbers.

$\endgroup$
1
$\begingroup$

You have to think, is it inclusive or exclusive. If inclusive then it includes 149 AND 201. Therefore the answer is 201 minus (1 less than 149) == 201 - 148.

Using algebra:

a ... b inclusive

== b - (a-1) == b - a + 1

So there you have your +1

$\endgroup$
1
$\begingroup$

In your case, you don't have to add +1 anywhere.

Just use the following formula:

The Number of Waiting Customers = Total Number of Customer - The Customers who are not waiting

Hence,

= 201 - 148 = 53 is your answer

$\endgroup$
0
$\begingroup$

Counting starts always with 1 (except you are a C programmer)

How many customers do we have:
let's count them
1,2,3,...,201
so we have 201 customers

How many customers are waited on
let's count them
149, 150, ..., 201
this is not counting because counting starts alway sith 1
so we do not know how many customers are waited on

therefore let's try to count the opposite:
How many customers are not waited on
1,2,3,...,148
this is counting because
counting starts always with 1

we have 148 customers that are not waited on

so how many customers are waited on?
it is the difference
201 -148

$\endgroup$
0
$\begingroup$

There are 3 cases:

  • include either the start or the end but not both

  • include both the start and end number

  • include neither the start nor the end number

Since the second case obviously has more numbers than the first, and the third case obviously has less, and you know the answer is close to "end minus start", you have the first one is "end minus start", the second is "end minus start plus 1" and the third is "end minus start minus 1".

In other words, the middle case (include one but not both) has the "expected" answer: end minus start.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .