I have $N$ items with a number on them, ranked $1,2,3,4,5,\dots,N$, and I select $P$ items at random.
What are the chances that 3 of the top 5 numbered items are in the $P$ chosen items?
I have $N$ items with a number on them, ranked $1,2,3,4,5,\dots,N$, and I select $P$ items at random.
What are the chances that 3 of the top 5 numbered items are in the $P$ chosen items?
There are $\binom{N}{P}$ ways of picking $P$ items from $N$ possibilities.
There are $\binom{N-5}{P}$ ways of picking them so that none of the picked items are in the top $5$; there are $\binom{5}{1}\binom{N-5}{P-1}$ ways of picking them so that exactly one is among the top $5$. And there are $\binom{5}{2}\binom{N-5}{P-2}$ ways of picking them so that there are exactly two among the top $5$.
So the total number of bad picks (picks that do not satisfy the desired conditions) is: $\binom{N-5}{P} + \binom{5}{1}\binom{N-5}{P-1} + \binom{5}{2}\binom{N-5}{P-2}.$
From this, it is easy to compute the probability you want.