If you toss a fair coin 20 times, what is the probability of 5 successive heads at any time? Express the answer as a decimal and round it off to 7 decimal places.
This problem is not original. It is roughly as difficult as a problem in the BMO. This problem is part of this set .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
C code:
int main(){
int ways[21];
for (int i=0;i<=4;i++) ways[i]=0;
ways[5]=1;
for (int n=6;n<=20;n++) ways[n]=2*ways[n-1]+twopow(n-6)-ways[n-6];
printf("%d", ways[20]);
}
int twopow(int n){
return (n==0?1:2*twopow(n-1));
}
[This is not a solution. It is converted from a note by Satyendra asking why he had a mistake in his understanding. I think it is valuable for others to understand this mistake, so I reproduced it here.]
Here is my approach:
Five consecutive coins can be chosen in 15 ways.Let us say we choose the first 5 coins.The probability that all of them show heads is
2
5
1
.Because we want exactly 5 consecutive heads the other 15 coins should show tails,the probability of that is
2
1
5
1
.Thus,probability of 5 consecutive heads is
2
2
0
1
∗
1
5
.
WHAT IS WRONG?
Other 15 coins need not show tails... So probability should be much more than what you have calculated... Eilon has got the accurate answer ... I checked on Wolfram..
20 coins are tossed where 5 are expected to be heads therefore the probability is;
5/20 == 1/4 == 0.25.
That awkward moment when rounding off of Brilliant answers gets yours right
Problem Loading...
Note Loading...
Set Loading...
Let W ( n ) be the number of permutations of length n of coin flips containing 5 successive heads. Our answer is 2 2 0 W ( 2 0 )
Let us look for a recursive formula for W ( n ) .
Consider coin permutations of length n, for a large n. We can separate these permutations into two types:
Type A: Permutations that have 5 successive heads in the first n-1 coins.
For each permutation in W ( n − 1 ) , we can stick an extra H or T at the end to get a unique permutation of this type. So there are 2 W ( n − 1 ) permutations of this type.
Type B: Permutations that do not have 5 successive heads in the first n-1 coins
In that case, the 5 successive heads must occur at the very end.
...<---length n-5-->...HHHHH
But the coin in the n − 5 t h spot cannot be heads, since that would make 5 successive heads in the first n-1 coins.
...<---length n-6-->...THHHH
What permutations can we put in in our n-6 long hole? Any n-6 long permutation that does not contain 5 successive heads.
Therefore there are 2 n − 6 − W ( n − 6 ) permutations of this type.
We thus obtain the recursive formula W ( n ) = 2 W ( n − 1 ) + 2 n − 6 − W ( n − 6 )
The formula is valid for n ≥ 6 and we have the initial values W ( k ) = 0 , k ≤ 4 and W ( 5 ) = 1 .
20 is small enough, so it is not too terrible to calculate W ( 2 0 ) bottom up.
It turns out W ( 2 0 ) = 2 6 2 0 0 8
2 2 0 2 6 2 0 0 8 = 0 . 2 4 9 8 7 0 3