I was reading this page on Wikipedia: Birthday Attack
I can understand up until how to approximate the minimal number of attempts for a given probability $$n(p; H) \approx \sqrt{2H \log \frac 1{1-p}}$$
Later on the page gave an expected value of number of attempts as $$Q(H) \approx \sqrt{\frac \pi 2H}$$
I think this is probably an integral over the first result times the probability. Can anybody give a few steps how to deduce the second result from the first result? I could not get the second result by myself.
Let $X$ be the number of attempts without a collision. Then, we have
$\mathbb{E}[X]$ $= \displaystyle\sum_{k = 1}^{\infty}k\Pr[X = k]$ $= \displaystyle\sum_{k = 1}^{\infty}\sum_{n = 1}^{k}\Pr[X = k]$ $= \displaystyle\sum_{n = 1}^{\infty}\sum_{k = n}^{\infty}\Pr[X = k]$ $= \displaystyle\sum_{n = 1}^{\infty}\Pr[X \ge n]$.
The probability that $X \ge n$ is simply the probability of having no collisions in $n$ attempts, which is the complement of the probability having a collision in $n$ attempts. Thus, $\Pr[X \ge n] = 1-p(n;H) \approx e^{-\tfrac{n^2}{2H}}$. (This approximation is given in the Wikipedia article in the equation immediately before the first equation in your question).
So, the expected number of attempts without a collision is approximately
$\mathbb{E}[X] = \displaystyle\sum_{n = 1}^{\infty}\Pr[X \ge n] = \displaystyle\sum_{n = 1}^{\infty}[1-p(n;H)] \approx \displaystyle\sum_{n = 1}^{\infty}e^{-\tfrac{n^2}{2H}} \approx \displaystyle\int_{0}^{\infty}e^{-\tfrac{x^2}{2H}}\,dx = \sqrt{\dfrac{\pi}{2}H}$.