TITLE: Expected number of keys to try
QUESTION [5 upvotes]: You have n keys on your key ring. One of them unlocks the front door, but you don't know which one. Find the expected number of tries it takes to open the front door by using the method of indicator random variables.

Note: We try keys without repeats since that key will never work if it doesn't work once.
My attempt:
Let X be the number of tries we need to open the front door.
We see that
$$X = 1 + X_1 + X_2 + X_3 + ... + X_n $$
where $X_i = 1$ if the $i^{th}$ try doesn't open the door and $X_i = 0$ if the try opens the door.
We need at least one try to open the door which is why there's a $1$ as the first term in the sum.
Using linearity of expectation:
$$E[X] = 1 + \sum_i {E[X_i]} = 1 + \sum_i {P(X_i = 1)}$$
Now attempting to find $P(X_i = 1)$. Well we've already tried $i - 1$ keys at this point, so there are $n - i + 1$ keys left. Of those $n - i + 1$ keys, $n - i$ of them are incorrect. Therefore, the probability that the $i^{th}$ try doesn't work is $\frac{n - i}{n - i + 1}$.
So,
$$E[X] = 1 + \sum_i {E[X_i]} = 1 + \sum_i {P(X_i = 1)} = 1 + \sum_{i = 1}^{n} \frac{n - i}{n - i + 1}$$ I typed this summation into wolframalpha and got some ugly answer with a $\psi$ in it, while the answer from the book I'm using gives the answer as $\frac{(n+1)}{2}$.
Where am I going wrong? Any advice is appreciated :)

REPLY [2 votes]: Here's another way to approach the problem.
Since we are attempting the keys without replacement, the probability that the ith attempted key works is:
$$P(\text{1st attempt works}) = \frac{1}{n} $$
$$P(\text{2nd attempt works}) = \frac{n-1}{n} \frac{1}{n-1} = \frac{1}{n}$$
$$P(\text{3rd attempt works}) = \frac{n-1}{n} \frac{n-2}{n-1} \frac{1}{n-2}= \frac{1}{n}$$
$$...$$
$$P(i^{th}\text{ attempt works}) = \frac{1}{n}$$
$$E[X] = (1)\frac{1}{n} + (2)\frac{1}{n} + (3)\frac{1}{n} + (4)\frac{1}{n} + .. + (n)\frac{1}{n} \\ = \frac{1}{n}[1 + 2 + 3 ... + n] \\ = \frac{1}{n}[\frac{n(n+1)}{2}] = \frac{n+1}{2}$$
Where we have used the sum of an arithmetic series to get $[\frac{n(n+1)}{2}]$