**Interview puzzle:** **If you have 20 people in a party and each shakes everyone else’s hand only once, how many handshakes take place?**

Use the below formula to get answer quickly.

Formula: N*(N-1)/2

If we put N=20, then answer will be 190.

**Let’s understand the formula.**

If there are n people at the party, then each person will shake hands with n-1 other people. So, with n people each making (n-1) handshakes, it appears at first sight that there is n(n-1) handshakes. However, each handshake will have been counted twice, i.e. A->B and B->A, so we must divide by 2. Total number of handshakes = n(n-1)/2

**Let’s see another variation of similar riddle asked in interview**

In a party, every person shakes hands with each other once, and there are 45 handshakes, how many people are there at the party?

Solution: Using formula N(N-1)/2

Given total handshakes = 45. Lets put it in the formula and solve the equation:

n(n-1)/2 = 45

n(n-1) = 90

n^2 – n – 90 = 0

(n-10)(n+9) = 0

From this n = 10 or -9 Consider the positive value the value of n will be 10.

Hence, number of persons at the party = 10