The other day, a question came up on a site called Brainly.com.

It went like this…

**In a cafeteria, all students shook hands with one another. There were 66 handshakes in total. How many students were in the cafeteria?**

As this question is quite interesting, I’m going to explain how you can answer it, and in the process – I’ll also be revealing its answer.

Now, to answer such a question we first have to perform a few experiments and ask ourselves mini questions. The data from these experiments and mini questions will have to be recorded, so that we can spot potential patterns which may ultimately help us create a formula to solve the main problem.

*EXPERIMENTS + MINI QUESTIONS*

**Will a pattern emerge??**

*1. Firstly, let’s think about how many handshakes there’d be with only one student in this cafeteria.* Well, we can say 0. Why would someone shake their own hand?

*2. Secondly, how many handshakes would there be if there are 2 students in this cafeteria?* Well, the answer to this question is 1. These two students would be able to shake hands with one another.

*3. Thirdly, how many handshakes would there be if there are 3 students in the cafeteria?* Haha, now things get a little more complicated… To answer this mini question, let’s attach the variables A, B and C to these students {A, B, C}.

It turns out that:

- A can shake hands with B (A,B).
- A can shake hands with C (A,C).
- B can shake hands with C (B, C).

*Possible combinations: (A, B), (A, C) and (B, C).

So the answer to this mini question has to be 3.

**4. Fourthly, how many handshakes would there be if there are 4 students in this cafeteria?** To answer this question we can use the same strategy we used to answer the third question. Let’s attach the variables A, B, C and D to these students {A, B, C, D}.

It turns out that:

- A can shake hands with B (A,B).
- A can shake hands with C (A, C).
- A can shake hands with D. (A, D).
- B can shake hands with C (B, C).
- B can shake hands with D (B, D).
- C can shake hands with D (C,D).

* Possible combinations: (A, B), (A, C), (A, D), (B, C), (B, D) and (C, D).

So, the answer to this mini question would have to be 6.

**5. Fifthly, how many handshakes would there be if there are 5 students in this cafeteria?** Using the same strategy we used to answer mini questions 3 and 4 – we will answer this question too. Let’s attach the variables A, B, C, D and E to these students {A, B, C, D, E}.

It turns out that:

- A can shake hands with B (A, B).
- A can shake hands with C (A, C).
- A can shake hands with D (A, D).
- A can shake hands with E (A, E).
- B can shake hands with C (B, C).
- B can shake hands with D (B, D).
- B can shake hands with E (B, E).
- C can shake hands with D (C, D).
- C can shake hands with E (C, E).
- D can shake hands with E (D, E).

So, the answer to this mini question would have to be 10.

Possible combinations: (A,B), (A, C), (A, D), (A, E), (B, C), (B, D), (B, E), (C, D), (C, E) and (D, E).

**CAN WE SOLVE THE MAIN PROBLEM WITH A FORMULA? WHAT PATTERN WILL DEFINE THE FORMULA?**

Alright… Now that we’ve performed a few experiments and have answered a few mini questions – let’s see if we can spot a pattern in our data. If we can spot a pattern in our data, we may be able to solve the problem relating to 66 handshakes. We need to find a pattern so that we don’t have to answer the main question using brute force and hundreds, if not, thousands of calculations. Remember, solving mathematical problems is all about spotting patterns.

To spot patterns, the best tool we can use is a table. Let’s create a table which contains the information we’ve just produced, related to the mini questions…

Student(s) |
Handshakes |
Pattern (Related to handshakes) |

1 |
0 |
0 |

2 |
1 |
1 |

3 |
3 |
1+2 |

4 |
6 |
1+2+3 |

5 |
10 |
1+2+3+4 |

Ok… Let’s look at this table carefully. It turns out that a pattern has emerged… As a pattern, we get tidy little sums. The kind of sums that Carl Friedrich Gauss was able to add up, thanks to diagrams such as the one below…

Diagram Explanation:

To add up the sum 1+2+3+4, you simply have to multiply 5 (which is the variable ‘s’ in this case) by (5-1) which is 4, then divide their product ( 5 x (5-1) ) by 2.

(5×4)/2 = 10 = 1+2+3+4.

Notice that:

- When there was one student in the cafeteria, there were 0 handshakes. (0) is 1 less than the number 1.
- When there were two students in the cafeteria, there was 1 handshake. (1) is 1 less than 2.
- When there were 3 students in the cafeteria, there were 3 handshakes. 3 =1+(2). 2 is 1 less than 3.
- When there were 4 students in the cafeteria, there were 6 handshakes. 6=1+2+(3). 3 is 1 less than 4.
- When there were 5 students in the cafeteria, there were 10 handshakes. 10=1+2+3+(4). 4 is 1 less than 5.

Also notice that:

**To understand the pattern below and how it was intuitively discovered, see the diagram which helped Carl Friedrich Gauss neatly add up sums such as 1+2+3+4.*

- [ 1 x (1-1) ] / 2 = 0 which is the same as : [ 1 x 0 ] / 2 = 0
- [ 2 x (2-1) ] / 2 = 1 which is the same as : [ 2 x 1 ] / 2 = 1
- [ 3 x (3-1) ] / 2 = 3 which is the same as : [ 3 x 2 ] / 2 = 3
- [ 4 x (4-1) ] / 2 = 6 which is the same as : [ 4 x 3 ] / 2 = 6
- [ 5 x (5-1) ] / 2 = 10 which is the same as : [ 5 x 4 ] / 2 = 10

**With this information, we can conclude that:**

s = number of students

h = handshakes

**[ s x (s-1) ] / 2 = h**

And this is the formula we can use to solve all student handshake problems such as the one mentioned at the top of this post. If we plug the value 66 into this formula, we will discover how many students there were in the cafeteria whereby 66 handshakes took place. At the beginning of this post, I said that I would reveal the answer to the main question. To reveal it though, I will have to solve a quadratic equation by completing the square. I will also have to turn the variable ‘h’ into 66. Let’s do this…

We now know that there were **12 students in the cafeteria**. Obviously, this problem could have been solved when we knew that s x (s-1) = 132, because 12 x 11 = 132. However, if you get a larger problem, you will need to produce a quadratic formula and complete the square to get an answer.

I hope that this post has shed light on how to solve handshake / people problems. If you have any questions or feedback, please leave a comment below. 🙂