## Invitation to Computer Science 8th Edition

The numbers from $1\ to\ n$, where $n$ is $even$, can be grouped into $n/2$ pairs of the form $1 + n = n + 1$ $2 + (n - 1) = n + 1$ $…$ $n /2 + (n/2 + 1) = n + 1$ giving a sum of $(n/2)(n + 1)$. This formula gives the correct sum for all cases shown, whether $n$ is $even$ or $odd$.
The numbers from $1\ to\ n$, where $n$ is $even$, can be grouped into $n/2$ pairs of the form $1 + n = n + 1$ $2 + (n - 1) = n + 1$ $…$ $n /2 + (n/2 + 1) = n + 1$ giving a sum of $(n/2)(n + 1)$. This formula gives the correct sum for all cases shown, whether $n$ is $even$ or $odd$.