There are n balls in the box. Each ball is uniquely numbered with natural numbers from 1 to n. There are no two balls with the same number. Someone pulls out a ball, writes down its number and puts it back in the box. Repeats this procedure k several times. What is the smallest k for which with probability greater than p each ball is pull out from the box at least 1 time?
[EDIT #1] The probability of pull out each ball is the same.
For example - n=150, p=95%, k=?
My partial solution is:
A - total number of possible outcomes
G - number of outcomes where each ball is pull out from the box at least 1 time
We search for $$k=k(n,p)$$ that $$\frac{A}{G}>p.$$ I think $$A=n^k$$ and $$G=\sum_{s_1=1}^{k-(n-1)}\hspace{0.4cm}\sum_{s_2=1}^{k-(n-2)-s1}\hspace{0.4cm}\sum_{s_3=1}^{k-(n-3)-(s1+s2)}\dots\sum_{s_{n-1}=1}^{k-1-\sum_{i=1}^{n-2}s_i}\frac{k!}{s_1!s_2!s_3!\dots s_{n-1}!(k-\sum_{j=1}^{n-1}s_j)!}$$
My questions are:
Is my partial solution correct?
What is the correct solution?
Is there a function with input N and P that will return K with direct calculation without testing each K from 1 to some big number?
I apologize for my poor English. I hope you understand me.
[EDIT #1]
Rename variables from N, K, P to n, k, p. [pre-kidney]
The probability of pull out each ball is the same. [pre-kidney]
Remove old picture and replace with LaTeX code. [N. F. Taussig]
Even though it was not explicitly stated, I am interpreting that each ball is chosen with equal probability, and the different draws are independent of each other. Also, to streamline the notation later I will rename your variables $N,K,$ and $P$ to their lower case versions $n,k$, and $p$ respectively. (Commonly in probability, upper case letters are used for random variables and lower case are used for non-random quantities.)
Then, we see that this problem is precisely the Coupon Collector's Problem and the function $k(n,p)$ you are interested computing can be expressed (in the notation of that wikipedia page) as finding the smallest $k$ such that $\mathbb P(T\leq k)$ is greater than $p$, written symbolically as $$ k(n,p)=\min\{k\in\mathbb N\colon\mathbb P(T\leq k)>p\}. $$ Finding $k(n,p)$ is equivalent to finding the CDF of the random variable $T$. There is no known closed form for all $n$, but there are bounds (presented on that wikipedia page) that are very accurate for large $n$.
For instance, using the Laplace-Erdos-Renyi bound of $$ \lim_{n\to\infty}\mathbb P(T\leq n\log n+cn)=e^{-e^{-c}},\qquad c\in\mathbb R $$ it follows (by setting $k=n\log n+cn$ so $c=k/n-\log n$) that $$ k(n,p)\approx \min\{k\in\mathbb N\colon e^{-e^{\log n-k/n}}>p\}, $$ and we can simplify the inequality to $\log n-k/n<\log\log (1/p)$, so that $$ k(n,p)\approx n\log n-n\log\log\Bigl(\frac{1}{p}\Bigr). $$
You'll notice a few things from this equation. First, $p$ plays a relatively small role: the main term is the $n\log n$, for instance in the case $n=150$ you asked about, the value of $k(n,p)$ will be near $150\log 150\approx 751.6$ with only minor dependence on $p$. (It is called the cutoff phenomenon by the way, where the time to reach some event depends almost entirely on $n$ and hardly at all on the cutoff probability $p$, so that it transitions from a probability close to $0$ to a probability close to $1$ in a very small window.)
Our approximation gives $$ k(150,.95)\approx 754.6 $$ by the way, so you can see how close this is to $150\log 150$. For comparison, $k(150,.05)\approx 750.5$ so you can see that we have only a $5\%$ confidence of getting all coins at least once after $750$ steps, all the way up to a $95\%$ confidence of getting all coins at least once after $755$ steps.