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
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
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.
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
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:
In Grade 7’s algebra, it is the expression . For n = 30: . For n = 6: . 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 .
Mathematicians write the number of pairs from n things as , and say it “n choose 2”: the number of ways of choosing 2 things out of n, when the order doesn’t matter. So .
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
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:
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:
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.
Seven friends lift their glasses of juice at a birthday, and every two of them clink glasses once. How many clinks?
Answer
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.
At a meeting, 78 handshakes were counted, everyone with everyone once. How many people were there?
Hint
Answer
Ten couples are at a wedding reception. Everyone shakes hands with everyone except their own partner. How many handshakes are there?
Answer
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
After a party, seven guests each say they shook hands with exactly three other guests. Can they all be telling the truth?
Hint
Answer
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
- How Many Number Plates Can a Province Make? Counting by multiplying, when the order does matter.
- How Many Ways Can You Walk to School? Counting routes along the lanes, and a triangle of numbers in which this topic’s numbers, 1, 3, 6, 10, 15, appear along a slanting line.
- Can You Cross Every Bridge Just Once? Dots and lines again, and why the handshake fact decides a walk.
- How Do You Schedule a League So Everyone Plays Everyone? (Grades 9–12) The 28 matches of an 8-team league fitted into rounds where nobody plays twice in a day.
- Must Two People Here Share a Birthday Month? (Grades 9–12) Another counting puzzle with a surprising answer.
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.
