-1

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

More generally, the problem can be stated as follows:

If you have n posts, how many sections are there between them?

The correct answer may be n − 1 if the line of posts is open-ended, n if they form a loop, or n + 1 if the posts do not occur at the end of the fence (for instance if the fence runs between two walls).

I don't understand the emboldened sentence. Can someone please illustrate it?

NNOX Apps
  • 1
  • 15
  • 118
  • 216

1 Answers1

3

Let $S_j$ denote section $j$ and $P_k$ denote post $k$. We can illustrate your question in the following way:

$$ S_1 \quad \color{red}{P_1} \quad S_2 \quad \color{red}{P_2} \quad S_3 \quad \color{red}{P_3} \quad S_4 \quad \ldots \quad S_n \quad \color{red}{P_n} \quad S_{n+1} $$