If everyone in a group of $n$ people shakes hands with each other person once, how many handshakes will there be? It might help to consider a particular example, like $n=7$. Show hint
If we want to visualise this, we might draw the people as dots around a circle, with a line between dots representing a handshake.
(When we have some number of objects with links between some of them, it’s called a graph. If there are links between all of them as in this case, it’s called a complete graph. There’s a whole branch of mathematics devoted to graphs, called graph theory.)
We can see that each person shakes hands with $6$ other people (or each dot has $6$ lines coming out of it). There are two ways we might work out the total number of handshakes (or lines) from this.
Looking at one of the dots, there are $6$ lines coming out of it, but then if we look at the next dot, one of its $6$ lines has already been counted, so there are $5$ new lines. Then the next dot has $4$ lines that haven’t already been counted, and so on down to the last dot with $0$ new lines. This gives a total number of handshakes of \[6 + 5 + 4 + 3 + 2 + 1 + 0 = 21.\]
Another way to approach the problem would be to reason that since there are $7$ dots, and each dot has $6$ lines, but each line is shared by $2$ dots, the total will be \[\frac{7\times6}{2} = 21.\]
Now it’ll be easier to tackle the question with $n$ people. The first method gives \[(n-1) + (n-2) + \cdots + 1\] which is an arithmetic sequence (see Section 7.7: Sequences) that sums to \[\frac{(n-1)(n-1+1)}{2} = \frac{n(n-1)}{2}.\] The second method gives the same answer ($n$ people each making $n-1$ handshakes shared between $2$ people). The fact that both ways of counting the handshakes must give the same answer actually makes a nice combinatorial proof that the sum of the numbers from $1$ to $n-1$ is $n(n-1)/2$.
A third possible way to count the lines in the graph would be to count the lines going from one dot to an adjacent dot in the circle, and the lines going around the circle skipping a dot, and the lines going around the circle skipping two dots:
In each of these cases there are $7$ lines, making $7\times3 = 21$ lines altogether. We can look at other numbers of dots to see the pattern. When $n=8$ we get $8 + 8 + 8 + 4 = 8\times3.5 = 8\times7/2$ lines. When $n=9$ we get $9\times4 = 9\times8/2$ lines. So in general it’s $n(n-1)/2$.