I came across this interview question recently, but can't quite find a generalized way of setting this up.

Now, we know that if $X$ denotes the minimum value rolled, then $X$ cannot be 6, since the rolls do not finish until a 5 is rolled. Therefore $E[X] = \sum\_{i=1}^{5} xP(X=x)$.

For $P(X=5)$, it is required that a 5 appeared before a 1, 2, 3, or a 4. Since the probability of this occurring is $\frac{1}{5}$, we can say that $P(X=5) = \frac{1}{5}$.

How would I go about calculating $P(X=x)$ for the remaining numbers? I have seen the following formula with respect to this question, but cannot understand how it's derived:

$P(X=x) = \frac{1}{x(x+1)}$.

Thanks in advance!