Learning How to Count (Avoiding The Fencepost Problem)

i dont get why ppl dont add this as a topic or at least a dedicate a page to this problem in mathematics, over the years i made countless mistakes regarding this, but after reading this it not only was my confusion totally dissolved i knew how to tackle the problem with ease, i mean you sometimes get long questions involving calculus and quadractic equations which you need to construst from the context of the questions and you usually don’t account for the fencepost problem ( not becuz its hard but becuz no one told you that this could be a problem !! ), seriously someone should inform the authorities about this.

@Joy: This is a problem that hits almost every programmer (“off by one” errors) and yeah, until you know it’s a problem it can be so easy to get bitten.

You’ve also just explained the difference between Natural Numbers, and Integers.

i have 65 ft of fence the panels can not be longer than 70 in AT WHAT DISTANCE DO I PUT THE POSTS TO ALLOW AN EQUAL NUMBER OF 5 1/2 IN BOARDS WITH EQUAL SPACING AND 4 IN POSTS THANKS

Fixed, like, 99% of my calculus class problems.

I teach programming, and have to explain indexing from zero to incredulous students a few times a year. It doesn’t help that some languages index from one (e.g. nth-child in css) whereas most index from zero.

I point out that even though we learn to count on our fingers, where the first number was one, everybody celebrated big time on the eve of the year 2000, whereas the true start of the new century was in fact 1st January 2001.

So no matter how strange it seems at first, we number years, centuries etc. from zero, but days of the month from 1. This is why the 20th century is the one where all the years, except the last, start with a 19.

Also, educational toys, videos, games and books for small children almost always skip zero altogether. I regard this as a mistake. Do they think they are protecting the kids from something?

I suspect we could clear up some (but not all) of these off-by-one issues if we actually had a commonly accepted way to say and write 0th. “Zeroth”? “Nullth”? “Nilth”? “Naughtth” “Noneth”? We can’t even agree on the most proper way to say 0.

Even programmers well versed in zero-indexed arrays call this index “First”, invariably abbreviated to 1st - uh-oh, there’s confusion already. It’s certainly not pronounced “Wunst”.

The Aha! moment for me was when I realized span is the line between two end-points. For a single line (1 span), there’re two end points (2 items); many times when we’re counting, we just go with the span calculation, and fail to add one more, the beginning point.

I frequently made error in boundry conditions during programming. Now I know why :). Great Article. Thanks

Great article. I was looking for a good explanation to point others to, this is definitely it.
On a similar note, I ran into the following problem a while ago:
Q: Given a month (0-based, i.e. 0=January, 11=December), return the quarter that the month lies in (again 0-based, i.e. 0=1st quarter, 1=2nd quarter etc).
A: Intuitively, you would divide the month by 4 to get the quarter. But that’s wrong, since 3/4 yields 0 (integer arithmetic), but 3 (April) should be in the 2nd quarter (1), not in the first quarter (0)! So instead of dividing by four you’ll have to divide by something that yields four pieces (i.e. 12/4=3).

@Bob: Thanks for the comment!

Errata on line:
I’d double-check with a smaller example – a fence of length 10 would have 2 posts, so yes, we need an “extra post”.

Should read “a fence of length{\bf 1}” instead of “a fence of length {\bf 10}”

Hi Bhaskar, thanks for the note. I clarified to say a fence of 10 feet needs two posts (assuming we need a post every 10 feet). Appreciate it!