# How rare is sharing of birthday amongst FaceBook friends

**Question:** Which is rarer, in general, you sharing a birthday with a friend, or some people in your friend list sharing a birthday?

To illustrate: Lets say you got 200 friends on FaceBook. So which is more likely a) You sharing a birthday with at least one of your 200 friends or b) Some of your 200 friends having a common birthday?

My solution:

Say you have N friends.

So total number of ways N people can have birthdays is 365^N

**Case a:** At least 1 person shares a birthday with you.

If none of them have the same birthday as you, then its possible in the following number of ways:

= 364^N

(This is because any of the N friends can have their birthday on the remaining 364 days other than your birthday)

So ways at least 1 friend shares a birthday with you is:

= 365^N – 364^N

If we convert this to probability, we need to divide with the total number of ways:

= (365^N – 364^N) / 365^N

= 1 – (364/365)^N

**Case b:** At least 2 of your friends share a common birthday.

Ways in which all the friends have a different birthday

= 365-p-N

= 365! / N!

= 365 * 364 * 363 … 365 – (N-1)

So ways in which at least two friends share a birthday:

= 365^N – 365 * 364 * 363 … 365 – (N-1)

Converting this into probability, we again need to divide with the total number of ways:

= 1 – (365 * 364 * 363 … 365 – (N-1) ) / (365^N)

So now its a comparison between the two probability values of two cases.

**case a: **1 – (364/365)^N

**case b:** 1 – (365 * 364 * 363 … 365 – (N-1) ) / (365^N)

1) Testing this for N=2

364/365= .997

case a: .005

case b: .003

2) Testing this for N=3

case a: .008

case b: .008

3) Testing for N=4

case a: .011

case b: .016

4) Testing for N=10

case a: .030

case b: .117

5) Testing for N=100

case a: 0.24

case b: 0.9999996927510721

6) Testing for N=200

case a: 0.422

case b: ~1 (almost)

7) Testing for N=366

case a: 0.634

case b: 1

**Summary:**

So for very small value of N i.e. 2 we have case a more likely than case b. But the case b crosses it at N=4 and converges very fast towards 1. Basically if you have more than 365 friends. Its certain that at least 2 of them will share birthdays.

**Appendix: **

Go source code for computing the values:

package main

import (

“fmt”

“math”

)func main() {

// Solving probability problem

// change the below value of N and compile and run the program for each value

N := 366// case a: 1 – (364/365)^N

x := 364.0 / 365.0

p1 := 1.0 – math.Pow(float64(x), float64(N))

fmt.Printf(“p1 = %+v\n”, p1)// case b: series 1 – (365 * 365-1 * …. * 365 – N) / 365^N

p2 := 1.0if N <= 365 {

for i:=0; i<N; i++ {

p2 *= float64(365-i) / 365.0

}

p2 = 1 – p2

}

fmt.Printf(“p2 = %+v\n”, p2)}

style!