Skip to content

← Math Further 6–8

How Many Handshakes at a Party of 30?

Topic 11 · Grades 6–8 · Counting pairs

What this builds on from class
  • Grade 7: Algebraic Expression
In this unit 8 sections
  1. Try it
  2. Three ways to count
  3. What’s going on
  4. More pairs
  5. Where the rule breaks
  6. Where this is used
  7. Questions
  8. Where to go next

It is the first day of the new school year in Baisakh, and Grade 7 has thirty students, some of them new. To break the ice, the class teacher makes a rule: before the first lesson, everyone shakes hands with everyone else, once.

The room fills with noise. Bibek, who likes to be first with an answer, shouts over it: “Thirty people, thirty hands each: 30 × 30 = 900 handshakes!” Gita isn’t so sure. Is Bibek right? And if he isn’t, how could you count the handshakes without making thirty people stand still while you watch every one?

Guess first. How many handshakes are there when 30 people each shake hands with everyone else once?

Pick an answer to see why.

Thirty people are too many to watch, so start with a party round a small table. Tap two people to make them shake hands. Can you get every pair to shake hands exactly once, and how many handshakes does it take?

Try it

Shake hands round the table

Tap one person, then another, and they shake hands: a line joins them, and the number in each circle is how many hands that person has shaken. A finished party’s total goes into the row of results. Try 3, 4, 5 and 6 people.

0Anu0Bibek0Dawa0Esha0Gita
People:
Handshakes
0
People done
0 of 5
People 345678 Handshakes ??????

Tap one person, then another: they shake hands. Get every pair to shake hands once, or press Next person shakes.

Now tap someone for Anu to shake hands with.

Nobody shakes their own hand. Tap two different people.

Anu and Anu shake hands. Handshakes so far: 0.

Anu and Anu have already shaken hands: once is enough. Find a pair with no line yet.

Anu and Anu take it back. People with an odd count: 0.

Anu shakes hands with everyone before: 0 new, 0 in all.

Everyone has shaken hands with everyone: 0 handshakes for 5 people. Try another number of people.

0 handshakes at random. People with an odd count: 0. Is it ever an odd number?

Try it

Small parties

Here are the parties the widget counts. Fill in the ones you haven’t done before you look.

People Handshakes More than the party before
2 1
3 3 2
4 6 3
5 10 4
6 15 5
7 21 6
8 28 7

Look at the last column. Each time one more person comes to the party, the handshakes go up by one more than the time before: 2, then 3, then 4. Why?

Use the pattern. How many handshakes are there at a party of 9?

Pick an answer to see why.

The newcomer

Think of the people arriving one at a time. The first sits down alone: no handshakes. The second shakes 1 hand. The third shakes hands with the two already there: 2 more. The fourth shakes 3. Each newcomer shakes hands with everyone already in the room, and that is one more person each time. The widget’s “Next person shakes” button counts this way.

So when the eighth person walks in, they add 7 handshakes, and a party of 8 has 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. And for the class of 30, the thirtieth student shakes 29 hands as they come in, so the class has

1+2+3+⋯+28+29 1 + 2 + 3 + \dots + 28 + 29

handshakes. That is a long sum. Is there a quicker way to do it?

Adding in pairs

Write the sum forwards and backwards, and add the two lines in pairs:

Forwards 1 2 3 … 27 28 29
Backwards 29 28 27 … 3 2 1
Added 30 30 30 … 30 30 30

Every pair makes 30, and there are 29 pairs. So twice the sum is 29 × 30 = 870, and the sum itself is half of that: 435.

Or pair the numbers inside one line: 1 + 29, 2 + 28, 3 + 27, all the way to 14 + 16. That is 14 pairs of 30, which is 420, with 15 left in the middle by itself: 420 + 15 = 435. Either way, nobody has to add 29 numbers one by one.

Three ways to count

The pairing gave 435. Now count the same handshakes in two other ways, and see that they agree.

Way 1: one newcomer at a time

This is the count you just did: 1 + 2 + 3 + … + 29 = 435. Draw it with dots, one row for each newcomer, and it makes a staircase.

1 + 52 + 43 + 34 + 25 + 1
Figure 11.1 A party of 6: the blue staircase is the handshakes, 1 for the second person to arrive, then 2, 3, 4 and 5. A second staircase (amber), turned round, fills every row to 6. Together they make 5 rows of 6, 30 dots, so one staircase is half of that: 15.

Make a copy of the staircase, turn it round, and fit it against the first. Every row now has the same number of dots, and the two staircases fill a rectangle. For a party of 6, Figure 11.1 shows rows of 1 + 5, 2 + 4, 3 + 3, 4 + 2 and 5 + 1: a rectangle of 5 rows of 6, 30 dots. So the staircase alone is half of it, 15. This is the adding-in-pairs trick drawn as a picture.

For the class of 30 the staircase has 29 rows, and the rectangle is 29 rows of 30: half of 870, 435.

Way 2: everyone counts their own

Now ask each student, when it is over, how many hands they shook. Every one of them says 29, everyone but themselves. (The number in each circle of the widget, once a party is finished, is one less than the number of people.) Thirty students, 29 each: 30 × 29 = 870.

But 870 is too many. When Gita and Bibek shake hands, Gita counts it, and Bibek counts it too. Every handshake is counted twice, once by each of the two hands in it. So the real number is half: 870 ÷ 2 = 435.

That is also what was wrong with Bibek’s 900. He counted 30 for each person, as if everyone shook their own hand too, and then he forgot that each handshake has two people in it.

Way 3: a table of who shook whose hand

AABBDDEEGGHH✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓
Figure 11.2 Six people, a row and a column each: 36 boxes. The diagonal is each person shaking their own hand, crossed out. The other 30 boxes hold every handshake twice: the blue ones above the diagonal, and the same handshakes again below it.

Make a table with a row and a column for each person. Put a tick where the row’s person shook hands with the column’s person. Figure 11.2 shows a party of six, by their first letters: Anu, Bibek, Dawa, Esha, Gita and Hari.

The table has 6 × 6 = 36 boxes. Six of them, along the diagonal, are each person and themselves: cross those out, and 30 are left. And each handshake has two boxes: Anu with Bibek is the box in row A, column B, and also the box in row B, column A. So there are 30 ÷ 2 = 15 handshakes, the boxes above the diagonal.

For the class of 30, the table has 30 × 30 = 900 boxes. That is Bibek’s 900! Take away the 30 on the diagonal: 870. Halve it: 435. So Bibek counted every box of the table, and the table shows exactly what to take away.

In the class of 30, how many hands does each student shake, and how many handshakes are there in all?

Pick an answer to see why.

What’s going on

Counting pairs

A handshake is a pair of people. Two people in it, and it doesn’t matter which you name first: Gita shaking Bibek’s hand is the same handshake as Bibek shaking Gita’s. So the question “how many handshakes?” is really: how many different pairs can you make from 30 people?

All three counts above say the same thing. Each person can be paired with every other person, and each pair is then counted from both ends, so for a group of n people:

number of pairs=n×(n−1)2 \text{number of pairs} = \frac{n \times (n - 1)}{2}

In Grade 7’s algebra, it is the expression n(n−1)2 \frac{n(n - 1)}{2} . For n = 30: 30×292=435 \frac{30 \times 29}{2} = 435 . For n = 6: 6×52=15 \frac{6 \times 5}{2} = 15 . The formula isn’t a rule to learn by heart: it is Way 2 written in letters. n people, n − 1 hands each, halved because every handshake has two ends.

Counting the same thing in two ways, and setting the answers equal, is called double counting. It is one of the most useful ideas in counting: Way 1 and Way 2 count the same handshakes, so their answers must be the same, and that proves the pairing trick: 1 + 2 + 3 + … + (n − 1) is always n(n−1)2 \frac{n(n - 1)}{2} .

Mathematicians write the number of pairs from n things as nC2 {}^{n}C_{2} , and say it “n choose 2”: the number of ways of choosing 2 things out of n, when the order doesn’t matter. So 30C2=435 {}^{30}C_{2} = 435 .

Triangular numbers

The numbers in the table, 1, 3, 6, 10, 15, 21, 28, are the triangular numbers: the numbers of dots you can arrange as a triangle, like the ten pins in bowling, or the staircase of Figure 11.1 with its corner smoothed. Each one is 1 + 2 + 3 + … up to some number, so the handshakes at a party of n are the triangular number that ends at n − 1.

Thirty students have shaken hands, 435 handshakes. A late student arrives and shakes hands with everyone. How many handshakes are there now?

Pick an answer to see why.

More pairs

Working backwards

At a reunion, someone counted 66 handshakes, everyone with everyone once. How many people were there?

Double it: 66 × 2 = 132. That is the number of people times one less than the number of people, two whole numbers next to each other. Which two neighbors multiply to 132? Try a few near the middle: 10 × 11 = 110, too small; 11 × 12 = 132. So there were 12 people. (Check: 12 × 11 ÷ 2 = 66.)

And not every number can be a count of handshakes. 100 handshakes would need two neighbors that multiply to 200, but 13 × 14 = 182 and 14 × 15 = 210. So nobody can ever count exactly 100 handshakes at a party where everyone shakes everyone’s hand.

Leagues

A football league of 12 teams plays every team twice, once at home and once away. How many matches is that?

Pick an answer to see why.

That last question shows something important. Halving was right for handshakes because a handshake between Gita and Bibek is the same as one between Bibek and Gita. When order matters, Gita’s team at home to Bibek’s is a different match from Bibek’s team at home to Gita’s, and nothing is counted twice.

The diagonals of a shape

Figure 11.3 All the lines between the six corners of a hexagon: 15 pairs of corners, 6 of them sides (solid) and 9 diagonals (dashed).

A diagonal joins two corners of a shape that aren’t next to each other. How many diagonals does a hexagon have?

Every pair of corners is joined by a side or a diagonal. Six corners make 6 × 5 ÷ 2 = 15 pairs, and 6 of those pairs are the sides. So a hexagon has 15 − 6 = 9 diagonals (Figure 11.3).

Or count from each corner: a corner can’t join itself or its two neighbors, so it has 6 − 3 = 3 diagonals. Six corners, 3 each, is 18, and each diagonal has two ends: 18 ÷ 2 = 9. For a shape with n corners:

diagonals=n×(n−3)2 \text{diagonals} = \frac{n \times (n - 3)}{2}

A 30-sided shape has 30 × 27 ÷ 2 = 405 diagonals, just 30 fewer than the class’s 435 handshakes: the 30 sides.

Where the rule breaks

Not everyone with everyone

The formula counts every pair. If some pairs don’t shake hands, count all the pairs, then take away the ones that don’t happen.

Five married couples are at a party. Everyone shakes hands with everyone except their own husband or wife. How many handshakes are there?

Pick an answer to see why.

Cards, not handshakes

At Tihar, each of the 30 students in the class sends a card to every other student. How many cards are sent? It sounds like the handshake puzzle, but it isn’t: Gita’s card to Bibek and Bibek’s card to Gita are two cards. Nothing is counted twice, so there is nothing to halve: 30 × 29 = 870 cards. Before you halve, always ask: is the thing I’m counting the same from both ends?

When the handshakes are anyone’s choice

At a real party nobody makes a rule, and people shake hands with whoever they like. Then the total can be anything. But one thing is still always true. Try it:

Try it

Shake hands with anyone

Tap pairs to make them shake hands, and tap a pair again to undo it, or press Random party. A person’s circle turns amber when they have shaken an odd number of hands.

0Anu0Bibek0Dawa0Esha0Gita0Hari
People:
Handshakes
0
All counts added
0
People with an odd count
0

Tap one person, then another, to make them shake hands; tap the pair again to undo. Or press Random party.

Now tap someone for Anu to shake hands with.

Nobody shakes their own hand. Tap two different people.

Anu and Anu shake hands. People with an odd count: 0.

Anu and Anu have already shaken hands: once is enough. Find a pair with no line yet.

Anu and Anu take it back. People with an odd count: 0.

Anu shakes hands with everyone before: 0 new, 0 in all.

Everyone has shaken hands with everyone: 0 handshakes for 6 people. Try another number of people.

0 handshakes at random. People with an odd count: 0. Is it ever an odd number?

However the hands are shaken, the number of amber people is even: 0, 2, 4 or 6, never 1, 3 or 5. The reason is Way 2 again: add up everyone’s count, and you get twice the number of handshakes, because each handshake gives two people one each. Twice anything is even. Now look at what makes up that even total. The even counts add up to an even number. Pair the odd counts off two at a time: each pair of odd numbers adds up to an even number. If one odd count were left over with no partner, it would make the whole total odd, and the total is even. So the odd counts always pair off exactly: there is an even number of them. This is called the handshake fact, and it is how Euler showed that the bridges of Königsberg can’t be walked: see Can You Cross Every Bridge Just Once?.

Where this is used

Questions

Ten people meet, and each shakes hands with every other once. How many handshakes?

Pick an answer to see why.

a.★

Seven friends lift their glasses of juice at a birthday, and every two of them clink glasses once. How many clinks?

Answer
b.★

Bhaskara’s palace has eight doors. In how many ways can exactly two of them be open? And in how many ways can two of his six tastes be mixed?

Answer

Which shape has exactly as many diagonals as it has sides?

Pick an answer to see why.

c.★★

At a meeting, 78 handshakes were counted, everyone with everyone once. How many people were there?

Hint
Answer
d.★★

Ten couples are at a wedding reception. Everyone shakes hands with everyone except their own partner. How many handshakes are there?

Answer
e.★★

A school’s chess club holds a tournament in which every player plays every other player once. There were 190 games. How many players were there, and how many games did each play?

Answer
f.★★★

After a party, seven guests each say they shook hands with exactly three other guests. Can they all be telling the truth?

Hint
Answer
g.★★★

Show that the handshakes of 5 people and of 6 people add up to 5 × 5, and that the same happens for any two parties of neighboring sizes. What do 435 and 465 make?

Hint
Answer

Where to go next

Where these facts come from
  • The handshake problem as triangular numbers, a fully connected network’s connections and a round-robin group’s matches as the same count; Gauss was not the first to know the formula: Wikipedia, “Triangular number”, read October 2026.
  • The handshake fact (the number of people who shook an odd number of hands is even), the sum of the degrees is twice the edges, proved by Euler in his 1736 paper on Königsberg’s bridges: Wikipedia, “Handshaking lemma”, read October 2026.
  • A fully connected network needs n(n − 1)/2 connections, which “makes it impractical for large networks”: Wikipedia, “Network topology”, read October 2026.
  • The first Nepal Premier League (2024, Kirtipur): 8 teams, seven league matches each, a playoff of qualifiers, eliminator and final, 32 matches in all: Wikipedia, “2024 Nepal Premier League”, read October 2026.
  • The 2019 Cricket World Cup: 10 teams in a single round-robin, each playing the other nine once, 45 matches: Wikipedia, “2019 Cricket World Cup”, read October 2026.
  • The Gauss schoolroom story: Sartorius von Waltershausen’s memorial of 1856, Büttner, the youngest pupil, the slate, “There it lies”, the end of the hour, told by Gauss “with amusement and relish” in old age, only “an arithmetic series” named; 1 to 100 first in the tellings Hayes found in 1938 (Bieberbach); told by hundreds, over a hundred versions in eight languages; essentially the same problem and solution in an eighth-century manuscript attributed to Alcuin of York: Brian Hayes, “Gauss’s Day of Reckoning”, American Scientist 94(3), May–June 2006 (the Internet Archive’s copy), read October 2026.
  • Bhaskara’s dates (1114–1185) and the Lilavati’s last chapter on combinations: MacTutor, “Bhaskara II”, read October 2026.
  • Bhaskara’s rule for combinations and its uses (prosody, buildings, music, medicine), the palace with eight doors (8, 28, 56, 70, 56, 28, 8, 1) and the six tastes (6, 15, 20, 15, 6, 1): Lilavati §§ 110–114 in H. T. Colebrooke, Algebra, with Arithmetic and Mensuration, from the Sanscrit of Brahmegupta and Bhascara (London, 1817; public domain), pages 49–50, Internet Archive, read October 2026.
  • The Bhagavati Sutra’s question about the six tastes: Wikipedia, “History of combinatorics”, read October 2026. Sushruta’s 63 combinations of six tastes: Wikipedia, “Combinatorics”, read October 2026.
  • Every count, table and answer in this topic (the small parties, 435 three ways, 5,050, 1,770, 465, 66 → 12, no party with 100, the leagues, diagonals, the couples, the cards, Bhaskara’s 28 and 15, neighboring parties making squares, the handshake fact for every party of up to six, the seven guests and the eight) was computed, mostly by listing every pair, in checks/textbooks/math-further-6-8/11/tmp/numbers.py.