TITLE: Obtaining irrational probabilities from fair coins?
QUESTION [23 upvotes]: Suppose I have access to a fair coin.  Is it possible to come up with a procedure that (1) returns TRUE with irrational probability (say $1/\sqrt{2}$) and FALSE otherwise, and (2) terminates in a finite amount of time?
I would think not, because at the end of the day I'm just assigning either TRUE or FALSE to sequences of coin flips, and any such assignment results in a rational probability.  However, I don't think there's harm in asking: is there some extraordinarily clever way to extract irrational probabilities?
[Edit] Alternatively, what if we relax condition (2) to "terminates with probability 1"?  (Thanks user6312!)

REPLY [10 votes]: Flip the coin until you get a tail.  If the number of heads is prime, return TRUE.  Otherwise, return FALSE.