# How to solve combination problem with mathematica?

How to find the smallest n s.t:

$$\binom{2500-n}{50}/\binom{2500}{50} < 0.5$$

• Just try all possible n: Catch[For[i = 0, i <= 2500, If[Binomial[2500 - i, 50] < 1/2 Binomial[2500, 50], Throw[i]]; ++i]] Commented Sep 6, 2022 at 4:21

Clear["Global*"]

NArgMin[{n, Binomial[2500 - n, 50]/Binomial[2500, 50] < 0.5}, n] //
Ceiling // Quiet

(* 35 *)


EDIT: Or

ArgMin[{n, Binomial[2500 - n, 50]/Binomial[2500, 50] < 1/2, n > 0},
n, Integers] // Quiet

(* 35 *)


Check,

Binomial[2500 - #, 50]/Binomial[2500, 50] & /@ {34, 35, 36} // N

(* {0.500818, 0.490663, 0.480711} *)

• In the context of Binomial, isn't the domain automatically set to Integer in mathematica?
– omg
Commented Sep 5, 2022 at 16:28
• No. Gamma or Factorial or Binomial are defined for real or complex arguments. Evaluate Binomial[5.3, 3.6] Commented Sep 5, 2022 at 16:32
• What does Binomial[5.3, 3.6] mean?
– omg
Commented Sep 5, 2022 at 16:35
• Binomial[m, n] // FunctionExpand evaluates to Gamma[1 + m]/(Gamma[1 + m - n] Gamma[1 + n]) Commented Sep 5, 2022 at 17:00
• It is. The third form shows the use of constraints and the last form shows use of a domain. Commented Sep 5, 2022 at 17:13

An alternative approach:

expression = Binomial[2500 - n, 50]/Binomial[2500, 50];
Min@ SolveValues[FunctionExpand[expression] < 1/2, n, Integers]

(* Out: 35 *)

• Can you explain the usage of Min@(why @) and FunctionExpand(why is it needed) and the difference between SolveValues and Solve?
– omg
Commented Sep 6, 2022 at 2:18
• @omg @ is a prefix notation for function application. In other words, f[x] can also be written as f@x. See the "Short Forms" section here. FunctionExpand is needed because it didn't work without it :-) I assume because Solve doesn't know how to transform the binomials on its own. SolveValues is equivalent to Solve, but it returns the values of the solutions rather than replacement rules. Compare Solve[x - 2 == 0, x] and SolveValues[x - 2 == 0, x]. Commented Sep 6, 2022 at 3:44
• Thanks for the detailed explanation! BTW, how to plot Binomial[2500 - n, 50]/Binomial[2500, 50] for integer domain?
– omg
Commented Sep 6, 2022 at 11:39
• @omg DiscretePlot[Binomial[2500 - n, 50]/Binomial[2500, 50], {n, 1, 150}] Commented Sep 6, 2022 at 12:23

Working in $$\mathbb{R}$$ instead of $$\mathbb{N}$$, we can ask

Reduce[Binomial[2500 - n, 50]/Binomial[2500, 50] < 1/2, n, Reals] // RootReduce

(*    34.0798 < n < 4916.92    *)


The results are given as Root objects (zeros of degree-50 polynomials) that can be converted to real numbers with N`.