A jar of mixed coins [closed]

This is a slight adaptation of a google interview question that I found entertaining.

You are given a jar with N coins, K of them are fair. The remaining coins have heads on both sides. You choose a coin at random from the jar and flip it m times.

1. If you get heads all m times, what is the probability that you selected a fair coin?

2. If m is 3, and N is 100, how many fair coins would need to be in the jar, for you to be at least 50% sure you selected a fair coin?

closed as off-topic by Deusovi♦, AJL, Peter Taylor, xnor, f''Nov 11 '15 at 18:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is off-topic as it appears to be a mathematics problem, as opposed to a mathematical puzzle. For more info, see "Are math-textbook-style problems on topic?" on meta." – Deusovi, AJL, Peter Taylor, xnor, f''
If this question can be reworded to fit the rules in the help center, please edit the question.

The probability is given by $P(fair|heads^m) = P(heads^m|fair) \cdot P(fair) / P(heads^m)$, where

$P(heads^m) = P(heads^m|fair)\cdot P(fair) + P(heads^m|nonfair)\cdot P(nonfair) = 1/2^m \cdot K/N + 1^m \cdot (N-K)/N$.

Hence,

$P_m = \frac{1/2^m \cdot K/N}{1/2^m \cdot K/N + 1^m \cdot (N-K)/N)} .$

Solving for $K$, we find that it must be 88.8.

• There are two questions. I presume your answer is for the first one and is expressed in %? – ErikE Nov 6 '15 at 0:29
• @ErikE, if you insert the numerical $m$ and $N$ into the formula for $P_m$ and set $P_m = 0.5$, you will have one unknown variable $K$. By solving this equation you get $K=88.8$, which answers the second question, right? – Carl Löndahl Nov 6 '15 at 9:03
• Okay I see what you mean, but do you see the problem with an answer "88.8 coins"? – ErikE Nov 6 '15 at 16:57
• I agree, the solution was correct, but I would have liked to see the answer 89 coins. (: – knrumsey Nov 6 '15 at 17:54
• 88.8 isn't "less proper", it's incorrect. :) but +1 anyway. – ErikE Nov 6 '15 at 23:57