If I shoot in the dark and pick a random number that's $
I would really like to understand the reasoning behind the answer, and not just a one-line formula.
If I shoot in the dark and pick a random number that's $
I would really like to understand the reasoning behind the answer, and not just a one-line formula.
Assuming that by picking a random number less than $n$ you mean randomly picking a natural number less than $n$ with uniform distribution over all such numbers, the answer is
$\frac{\pi(n-1)}{n-1}\;,$
where $\pi$ is the prime-counting function, since $\pi(n-1)$ of the $n-1$ numbers you're choosing from are prime. That article has a lot of information on that function, which it wouldn't make sense to reproduce here; feel free to ask if there's more you want to know that you can't find there.
The average number of trials until the first success given a probability $p$ of success is $1/p$, so the average number of trials in this case would be
$\frac{n-1}{\pi(n-1)}\;.$