A bag contains 5 coins. Four of them are fair and one has heads on
both sides. You randomly pulled one coin from the bag and tossed it 5
times, heads turned up all five times. What is the probability that
you toss next time, heads turns up. (All this time you don't know you
were tossing a fair coin or not).
The probability of getting n consecutive heads is
P(n heads) = 1/5 * 1 + 4/5 * (1/2)^n,
Thus, the probability of getting a head on the n+1st roll given that
you have gotten heads on all n previous rolls is
P(n+1 heads | n heads) = P(n+1) / P(n)
= ( 1/5 * 1 + 4/5 * (1/2)^(n+1) ) / ( 1/5 * 1 + 4/5 * (1/2)^n ).
Multiplying numerator and denominator by 5* 2^(n-1) and recognizing 4
as 2^2 gives
P(n+1 heads | n heads) = (2^(n-1) + 1) / (2^(n-1) + 2)
put n=5 in above expression probability that you toss next time, heads turns up will be 17/18