How to generate (with perfect probability) a random number between 0 and 100, by flipping a coin (50/50 probability) exactly 7n times?

62 Views Asked by At

Hello I'm new here and I've just registered an account to be able to ask someone with more mathematical experience this question I got from a student of mine (Refer to title).

They claim that this number using their method can be determined by flipping a coin any multiple of 7 times (such as 14, 21, etc.), and have demonstrated this method's practicality by determining this number usually within 10 seconds,

though very interestingly they also claim they have to exceed 7 seven flips only 21.875% percent of the time, and 4.785% for 14 flips (where are they getting these numbers?).

Personally I have a feeling they're trying to just pull my leg in front of the class (I'm an Algebra I/Geometry teacher, by no means a pro mathematics guru), but this student in particular has time and time again alluded to already known higher maths (I'm talking calculus, and some really arcane computer science jargon), and I'm wondering if there's any truth to this whole coin-flipping thing.

Oh and one more thing, they've given me a hint that their method can be conveniently expressed as computer code. I'm not really experienced with coding anything beyond a HTML webpage so I don't know if this could be of any significance.

And finally, please excuse me for my informal format of a question but I would really like to see where they're going with this. Thank you for your time and consideration.

1

There are 1 best solutions below

3
On BEST ANSWER

Here is one algorithm: flip a coin 7 times, and write down zeros and ones for heads and tails. This gives a binary number between $0$ and $127 = 2^7 - 1$ inclusive.

If the number is over $100$, discard it and try again. This happens with relatively low probability, since there are only $27$ bad outcomes out of $128$ possibilities.

In particular, this occurs about $21.1\%$ of the time. Failing twice in a row happens about $4.4\%$ of the time, and failing three times in a row occurs less than one percent of the time.