Range of balls needed in lottery for 0 and 1 match to be equally likely with 5 balls drawn The question is if there is a lottery in which 5 balls are drawn randomly without replacement, what is the number range of the balls needed so that matching exactly 0 of those balls or matching exactly 1 of them is equally likely (or as close to equally likely as possible)? Assume all balls are numbered sequentially from 1 to n (such as 1,2,3...n).  Solve for n.
I know this can be solved by trial and error but is there a mathematical way to get the answer without first guessing and then making corrections/adjustments?
I was also able to solve it using wolframalpha but how can someone solve it mathematically, either getting an exact same probability for matching exactly 0 or 1 ball(s) or such that the probability of matching exactly 0 or 1 is the closest it can be?
The idea is a hypothetical lottery wants to make it easier to match at least 1 ball so maybe more people play or people that play continue to do so.  So the lottery designer is interested to first find out where 0 and 1 matches are about equal, then adjust it slightly to favor at least 1 match.
 A: Here's what I think you're asking, generalized slightly. There are $n$ balls numbered $1, \ldots, n$. Lottery players choose $k$ distinct numbers with $k < n$, then $k$ balls are drawn. Tickets are rewarded according to the number of matches.
Each ticket should have the same probability distribution, so wlog assume that the player chooses $1, \ldots, k$. Then:


*

*The number of zero-match drawings is $\binom{n-k}{k}$, the number of $k$-element subsets of $\{k+1, \ldots, n\}$. Note that at least one match is guaranteed unless $2k \leq n$.

*The number of one-match drawings is $k \binom{n-k}{k-1}$, the number of one-element subsets of $\{1, \ldots, k\}$ times the number of $k-1$-element subsets of $\{k+1, \ldots, n\}$.


Solving for $n$:
\begin{align*}
\binom{n-k}{k} &= k \binom{n-k}{k-1} \\
\frac{(n-k)!}{k! (n-2k)!} &= \frac{k (n-k)!}{(k-1)! (n-2k+1)!} \\
\frac{(k-1)!}{k(k!)} &= \frac{(n-2k)!}{(n-2k+1)!} \\
\frac{1}{k^2} &= \frac{1}{n - 2k + 1} \\
n &= k^2 + 2k - 1
\end{align*}
So $n = 34$ for $k = 5$.
If you have the R programming language and the tidyverse package installed, then the following function will let you simulate the lottery. balls and draws are the total number of balls and the number of balls drawn ($n$ and $k$ in my notation above), and trials is the number of simulations to run. The output is a data frame with two columns: num_matches lists integers from 0 to draws, and num_trials shows the number of trials that gave that number of matches with a ticket marked 1, ..., draws.
lottery <- function(balls, draws, trials) { 
  tibble(trial=rep(1:trials, each=draws),
         result=as.vector(replicate(trials,
                          sample(1:balls, draws)))) %>% 
  group_by(trial) %>%
  mutate(match=(result<=draws)) %>% 
  summarize(num_matches=sum(match)) %>%
  ungroup() %>%
  group_by(num_matches) %>%
  summarize(num_trials=n())

}
I tried running this with 200,000 trials and got good results:
> lottery(34, 5, 2e5)
# A tibble: 5 x 2
  num_matches num_trials
        <int>      <int>
1           0      85350
2           1      85338
3           2      26260
4           3       2941
5           4        111

  > lottery(62, 7, 2e5)
  # A tibble: 6 x 2
    num_matches num_trials
          <int>      <int>
  1           0      82073
  2           1      82850
  3           2      29922
  4           3       4777
  5           4        364
  6           5         14

I'll note that as $k$ increases, the outcomes of this lottery seem to reproduce the Poisson distribution for $\lambda = 1$, and the probabilities of $0$ and $1$ matches approach $1/e$. I can't think of a quick explanation for this immediately. The probability of zero matches in this lottery is \begin{align*}\frac{ \binom{k^2 + k - 1}{k}}{\binom{k^2 + 2k - 1}{k}} &= \frac{ \frac{(k^2 + k - 1)!}{k! (k^2-1)!}} {\frac{(k^2 + 2k-1)!}{k! (k^2 + k + 1)!}} \\
&= \frac{(k^2 + k + 1)!^2}{(k^2 + 2k - 1)!(k^2 - 1)! } \\
&= \frac{k^2 (k^2 + 1) (k^2 + 2) \cdots (k^2 + k - 1)}{(k^2 + 2k) (k^2 + 2k + 1) \cdots (k^2 + 2k - 1)} \\
&= \prod_{i=0}^{k-1} \frac{k^2+i}{k^2 + 2k + i} \\
&= \exp \left( -\sum_{i=1}^{k} \log \left( 1 - \frac{2k}{k^2 + 2k + i} \right) \right)\end{align*}
and perhaps that last sum could be shown to go to $1$ by a clever use of asymptotics.
A: Actually I think I have a solution to this specific problem.
to match exactly 0 balls: ${5 \choose 0}$ * ${n \choose 5}$
to match exactly 1 ball : ${5 \choose 1}$ * ${n \choose 4}$
Here n is the number of "losing" balls so the final answer will be 5+n as the highest numbered ball.
So we know ${n \choose 5}$ is n (n-1) (n-2) (n-3) (n-4) / 120
and we know $5 * {n \choose 4}$ is 5 * n (n-1) (n-2) (n-3) ( ) / 24 (empty parens to show "missing" term)
multiply the 2nd equation by 5/5 to get 25 * n (n-1) (n-2) (n-3) ( ) / 120
now we can drop the /120 since both equations have it and then we multiply both equations by (n-4) (since it is missing from the bottom one)
Now the equations are exactly the same except the top one has an extra (n-4) and the bottom one has a 25 so if we are solving for both equations being equal, that means that 25 = (n-4) so n = 29 which means there have to be 29 losing balls for the lottery to have even chances for exactly 0 or 1 matches, so if the highest numbered ball is 34, I think it is a solution.
However, if the probability of exactly 0 or 1 matching balls is not exactly equal, this method might not work.
