Difficulty level:
College probability.

Pi From Coin Flips

Bert takes two quarters from a sack, flips them, and gives them to you. He repeats this until the sack is empty or the number of heads flipped so far equals the number of tails. Let r be the average number of dollars you receive.

How many pairs of quarters are in the sack?

The answer is \(\pi \hspace{1 pt} r^2\), rounded to an integer.


It is interesting that a simple probability question generates an answer involving π, and that is why I wrote this page. For those who want to follow the math, a demonstration follows.

Notation: You should see the Greek letter pi here: π, and a wiggly "approximately equals" symbol here: ≈.


To see the answer above is correct, we start with the probability there are at least i+1 pairs of flips before heads equals tails. (Here is a proof.) The probability is: $$\frac{(2i)!}{4^ii!^2}.$$ Let n be the number of pairs of quarters in the sack. To find the average number of pairs of quarters you receive, we add up the probability you get at least one pair, the probability you get at least two, the probability you get at least three, and so on up to n. That is, we just add up the values of the above expression for i from 0 to n-1. Again, I omit the proof of this, but you can test the first few values to check. The sum, and hence the average number of pairs of quarters you receive is: $$\frac{2n(2n)!}{4^nn!^2}.$$ A pair of quarters is half a dollar, so the average number of dollars you receive is half that, and it must equal r, since we are given that r is the average number of dollars received: $$\frac{n(2n)!}{4^nn!^2} = r.$$ Now, there is an approximation for π called Wallis' product. Wallis' product can be derived using integration by parts, but we'll just skip that and show the product: $$\frac{\pi}{2} = \frac{2}{1} \frac{2}{3} \frac{4}{3} \frac{4}{5} \frac{6}{5} \frac{6}{7} \cdots \frac{2n}{2n-1} \frac{2n}{2n+1} \cdots $$ Although the product goes on for infinitely many terms, we will chop it off at term n. That makes it only an approximation instead of exactly π / 2, but it's close enough for our purposes. Then we'll insert some extra terms. The extra terms are each equal to one (e.g. 2/2), so they don't change the value of the product, but they help us rewrite the product with factorials. The symbol "≈" means "approximately equals": $$\frac{\pi}{2} \approx \frac{2}{1} \frac{2}{2} \frac{2}{2} \frac{2}{3} \frac{4}{3} \frac{4}{4} \frac{4}{4} \frac{4}{5} \frac{6}{5} \frac{6}{6} \frac{6}{6} \frac{6}{7} \cdots \frac{2n}{2n-1} \frac{2n}{2n} \frac{2n}{2n} \frac{2n}{2n+1}. $$ Since all the numerators are even and there are 4n of them, we can separate the numerators into 24n times 1⋅1⋅1⋅1⋅2⋅2⋅2⋅2⋅3⋅3⋅3⋅3 ... nnnn. That's 24n times n!4. So the product of the numerators is 24nn!4, which equals 42nn!4.

Taking the first pair of each four denominators, we have 1⋅2⋅3⋅4 ... (2n-1)⋅2n, which is (2n)!. Taking the second pair of each four, we have 2⋅3⋅4⋅5⋅6⋅7 ... 2n⋅(2n+1), which is (2n+1)!. So the product of the denominators is (2n)!(2n+1)!.

Now we rewrite our approximation for π / 2 using the expressions we found for the numerators and the denominators: $$ \frac{\pi}{2} \approx \frac{4^{2n}n!^4}{(2n)!(2n+1)!} = \frac{4^{2n}n!^4}{(2n)!^2} \frac{1}{2n+1}. $$ If n is large, this is approximately: $$ \frac{\pi}{2} \approx \frac{4^{2n}n!^4}{(2n)!^2} \frac{1}{2n}. $$ And let's multiply by 2: $$\pi \approx \frac{4^{2n}n!^4}{(2n)!^2} \frac{1}{n}.$$ Now we are ready to find n (the number of pairs of quarters in the sack) as a function of r (the average number of dollars you receive). Take the equation we had earlier with n and r and square both sides: $$\frac{n^2(2n)!^2}{4^{2n}n!^4} = r^2.$$ Multiply both sides by 42nn!4 / (n(2n)!2): $$n = \frac{4^{2n}n!^4}{(2n)!^2} \frac{1}{n} r^2.$$ We recognize on the right the approximation we found for π, so replace it with π: $$n \approx \pi \hspace{1 pt} r^2.$$ Therefore, there must be about π r2 pairs of quarters in the sack.

How good is this approximation? It's actually very good. When there are 500 pairs of quarters in the sack, the average payoff, r, is about 12.61. And π 12.612 is 499.6, which rounds to 500. Even with just three pairs, we get the correct answer. At three pairs, the average payoff is $.9375. π times that squared is about 2.76, which rounds to three.


Pairs of quarters:
The average win will be about $. With this value for r, π r2 is .

Last play:

  • Flips: .
  • Reason for stopping:
  • Money won: $0.
  • Average win: $0 (total winnings of $0 divided by 0 plays).
  • Estimated average: $0.
  • Error: 0%.

How many:

© Copyright 1998 by Eric Postpischil.