High School Index numbers vs. Quantity in a group

Click For Summary
The discussion revolves around the concept of counting elements in a group and the confusion arising from indexing in programming. It highlights that when calculating the number of elements between two indices in a list, one must add one to the difference to account for inclusivity. This is referred to as a "fence-post" error or an "off-by-one error" (OBOE). The participants note that this counting method is often not taught in early education but is covered in computer science courses. The conversation concludes with a shared understanding of the importance of this concept in both mathematics and programming.
1plus1is10
Messages
51
Reaction score
0
"Quantity in a group"
If you have 6 apples and you subtract 4, then you have 2 apples left "in the group".

"Quantity in an Indexed group"
I'm a computer programmer - I manipulate arrays of data (a.k.a. matrix)
In a math formula format: x1, x2, x3... xn
(as a side note - in a computer format: x[0], x[1], x[2]... x[n-1])
If I want the "quantity" from 6 to 4, then I always have to add 1 (6-4=2, 2+1=3 quantity)
Quantity of 3: x4, x5, x6

Surprisingly, I was never taught this in grade school or high school.
Not to mention I always thought it had to do with the fact that a computer's array starts with index 0: x[0]
(It doesn't, although that fact adds confusion when turning math formulas into code)

My question is: Does this "add 1" scenario have a mathematical name?
(I've been trying to Google about it to add a note/comment to my code to explain "+1" without sounding stupid)

Thanks
 
Mathematics news on Phys.org
1plus1is10 said:
"Quantity in a group"
If you have 6 apples and you subtract 4, then you have 2 apples left "in the group".

"Quantity in an Indexed group"
I'm a computer programmer - I manipulate arrays of data (a.k.a. matrix)
In a math formula format: x1, x2, x3... xn
(as a side note - in a computer format: x[0], x[1], x[2]... x[n-1])
If I want the "quantity" from 6 to 4, then I always have to add 1 (6-4=2, 2+1=3 quantity)
Quantity of 3: x4, x5, x6

Surprisingly, I was never taught this in grade school or high school.
Not to mention I always thought it had to do with the fact that a computer's array starts with index 0: x[0]
(It doesn't, although that fact adds confusion when turning math formulas into code)

My question is: Does this "add 1" scenario have a mathematical name?
(I've been trying to Google about it to add a note/comment to my code to explain "+1" without sounding stupid)

Thanks
The closest I can come up with for a name is when you miscount -- a "fence-post" error. The number of elements in the range ##x_m## through ##x_n##, inclusive, with ##n \ge m##, is n - m + 1. For example, the number of elements in the range ##x_3## through ##x_7##, again inclusive, is 7 - 3 + 1 = 5. They are ##x_3, x_4, x_5, x_6, x_7##. This type of counting typically isn't taught in grade school or high school (that I am aware of), but it is taught in basic computer science classes, or possibly in probability and statistics courses.
 
  • Like
Likes jbriggs444 and 1plus1is10
Wow again...
This also explains the age-old problem/confusion with year/century (e.g. the 1900's is the 20th century).
Cool man.
 
Here is a little puzzle from the book 100 Geometric Games by Pierre Berloquin. The side of a small square is one meter long and the side of a larger square one and a half meters long. One vertex of the large square is at the center of the small square. The side of the large square cuts two sides of the small square into one- third parts and two-thirds parts. What is the area where the squares overlap?

Similar threads

  • · Replies 2 ·
Replies
2
Views
641
  • · Replies 1 ·
Replies
1
Views
808
  • · Replies 26 ·
Replies
26
Views
843
  • · Replies 21 ·
Replies
21
Views
3K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
235
Views
14K