Probability of guessing the correct password

probabilitypuzzlesequences-and-series

Suppose I need to guess a password of one digit. Each time I'm wrong the password increases by another digit. What's the probability that I can correctly guess the password (assuming I have unlimited amount of time and the number is all uniform)?

My approach: since the number is generated random, it doesn't matter what strategy we adopt to guess the number. So consider the following sequence of guess $1, 21, 221, 2221, 22221, …$. The probability that the password results in $k$-th guess is then $\frac{1}{10^n}$. Thus the total probability is $\sum_n \frac{1}{10^n}$. So the probability is $0.11111111111… = \frac{1}{9}$.

Is my approach correct, and if so, is there any better solution for this. The fraction $\frac{1}{9}$ seems to suggest an easier perspective to look at this puzzle.

Best Answer

What is the probability that you keep failing indefinitely?

Probability that you fail first time is $\cfrac{9}{10}$

Probability that you fail twice in a row? Now here I assume that the person guessing the password can keep track of what they guessed and does not choose from the one's that are obviously incorrect.

Say you guessed $2$ first time and it was wrong. Now one digit gets added. So you need to guess from $100$ numbers ($00 - 99$) but you also know it cannot be any number between $20$ and $29$.

So probability that you fail twice in a row is,

$\cfrac{9}{10} \cdot \cfrac{89}{90} = \cfrac{89}{100}$

Now for the third guess, say you guessed $2$ the first time and $18$ the second time and failed both times, you know the three digit number is not between $200 - 299$ and you also know it is not in $180 - 189$.

Probability that you fail thrice in a row is,

$\cfrac{9}{10} \cdot \cfrac{89}{90} \cdot \cfrac{889}{890} = \cfrac{889}{1000}$

You see the denominator of the third is divisible by numerator of the second, denominator of the second by the numerator of the first?

Eventually at the end of $n$ guesses, probability that you failed in all of them is

$P(F) = \cfrac{10^n - 10^{n-1} - 10^{n-2} ... - 10^0}{10^n} $

So probability that you succeed in $n$ guesses,

$P(S) = 1 - P(F) = \cfrac{10^n - 1}{9 \cdot 10^n}$

Now as $n \to \infty$, what do you get for $P(S)$?