When each of n people shakes hands exactly once with every other person, every handshake is just a pair of people. So the number of handshakes is the number of ways to choose 2 people from n:
Handshakes = nC2 = n(n − 1)/2
The reasoning behind it: each person shakes n − 1 hands, giving n(n − 1), but that counts every handshake twice, once from each side. For more on choosing, see permutations and combinations.
Worked example 1: ten people
10 people, all shaking hands once: 10 × 9 ÷ 2 = 45 handshakes.
Questions often give the total and ask for n. Double the total and look for two consecutive numbers with that product.
Worked example 2: working back from 66
66 handshakes means n(n − 1) = 132 = 12 × 11, so there were 12 people.
If handshakes happen only between two groups, such as 5 men each shaking hands with 4 women but not with each other, the count is simply 5 × 4.
Worked example 3: two groups
5 men each shake hands with each of 4 women, and nobody else: 20 handshakes.