The following is an interview question.
You have a drawer with an infinite number of two colors of socks, which exist in equal probability. What is the expected number of attempts at taking out socks individually from the drawer before a matching pair is found?
Let $X$ be the number of socks required to obtain a matching pair. Clearly for all $n\geq 3,$ we have $$P(X=n)=1.$$ Also, $P(X=1)=0,$ $P(X=2)=\frac{1}{2}.$ So, the expected number is \begin{align*} E(X) & = \sum_{x=2}^\infty x P(X=x) \\ & = 1+ \sum_{x=3}^\infty x, \end{align*} where the series diverges. So, the expected number is infinity.
Am I solving the question correctly?
Following @Japp's suggestion in his answer below, I calculated $P(X=n)$ wrongly for $n\geq 3.$
In fact, it is $$P(X=3) = \frac{1}{2}\quad \text{and} \quad P(X=n) = 0\quad \text{for all }n\geq 4.$$ It follows that $$E(X) = 2.5.$$
The line:
is incorrect. Here you are confusing two probabilities. If you take three socks, the probability of getting a matching pair is $1$. But $P(X=n)$ does not mean that. It means the probability of needing to take $n$ socks before getting a matching pair.
What you therefore actually have is that $P(X=n)=0$ for $n>3$, since you never need more than $3$ socks till you get a matching pair. Now you just have to work out the correct value for $P(X=3)$, and plug that into the calculations for the expectation.
Remember that the sum of the probabilities for all possible distinct outcomes is 1.