“The numbers don’t tally!” – a serial counting problem

How many numbers are there from 7 to 26 (both inclusive)? How do you calculate your age?

Both solutions require you to count from one number to another. And if you’re quick-witted, you might have deduced that a subtraction shortens the process considerably. However, be careful of how you subtract.

For the first question, if you take 26 – 7, you get 19. But there are 20 numbers:
7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26

For the second question, you simply take the current year minus the year you were born in (let’s leave the exact months out of this). So I’m born in 1977, and as of this writing, it’s the year 2009, so I’m 2009 – 1977 = 32 years old. Which is correct. Wait, did I just tell you my age?

The army equipment

I’m going to relate to you an incident which happened when I was enlisted in the army. No it’s not a war story. It is, surprisingly, a counting problem.

I was a lowly private then, assigned to the store to help. On a particular day, the lance corporal I was helping was making sure of equipment stock. Basically ensuring that the stock number of a piece of equipment on paper, physically reflects the stock number of that piece of equipment in the store.

We took down all the (communications, I think) equipment down from the racks, and placed them neatly on the floor. Since the racks were now empty, we might as well clean them (army efficiency…). After that, the lance corporal and I started to count the equipment on hand.

It was a while later, and I was counting my part of the equipment, when the lance corporal swore. He was pacing, and gesticulating, and his face was contorting in expressions of worry I’ve never seen before.

The lance corporal had counted the pieces of equipment. It tallied with what was recorded on paper. Then he sorted them by serial number (there was one on each piece of equipment). Then he matched them with the serial numbers recorded in the system. It was correct too.

And because the serial numbers were in increasing order, differing by 1, he did the subtraction trick. And found to his horror of horrors that it wasn’t the number he counted! Hence his panic.

The records said there were 20 pieces of this equipment on hand. But the subtraction gave him:
26 – 7 = 19!

What went wrong?

The problem was, the lance corporal didn’t count the equipment with serial number SERIAL0007.

The age problem

Let’s look at the age problem again. Say there’s a baby born in the year 2000. Which year would the baby be 1 year old? 2001. Which year would the baby be 5 years old? 2005.

How is the age calculated? Take the current year minus the birth year.

It works, because the birth year is not counted.

Back to the serial numbers

In the case of the serial numbers, each serial number had to be counted in.

Serial numbers SERIAL0007 and SERIAL0008 means there were 2 pieces of equipment, even though
8 – 7 = 1

Thus, the number of pieces of equipment for serial numbers SERIAL0007 through to SERIAL0026 should be 26 – 7 (+ 1) = 20

Conclusion

A series of numbers is easy to count the number of its members. Just use subtraction.

Just be careful to note whether the start of the series have to be counted.

=====
* In Singapore, ‘A’ level refers to the GCE ‘A’ levels, commonly taken by students at around 18 years old. If one passes this, one can proceed to the university (generally speaking). And in Singapore, having a degree means a lot.

And young men with an ‘A’ level certificate entering the army may sometimes be viewed or referred to with a slight derogatory attitude, albeit lighthearted and with a fun undertone. And with their status sometimes pronounced as “air level”.

You may also like these posts

This kind of counting problem can often be handled by reverting to the old “take away” concept that so many of us learned in our single digit years. What you should really be doing to count items in the inventory is to “take away” all the numbers that aren’t there; don’t take away the first number that is.

In computer programming, this “0-based” versus “1-based” problem comes up often. For instance, in C, to define an int array with 10 elements, you use:

int C[10]

but the elements of C are C[0] (the 1st element), C[1] (the 2nd element), … C[9] (the 10th element.) It’s tempting to ask for the 10th element of C as C[10], but that’s off by one. In fact, that’s the title of the Wikipedia article about this issue:

I’ve heard this referred to as a “fencepost error”, in reference to old questions like “A farmer wants to put up a 50 foot length of fence, with a fencepost every 10 feet. How many fenceposts will he need?” One natural response is to divide to get 5, but this of course neglects the very first fencepost.

“There should be 6 fenceposts! You left out one at that end!”
“I wanted to express the concept of never-ending in my own way. So I deliberately left the end post out.”
“Oh you’re just being cheap…”
“If you say so…”