private static double Factorial(int value) {
for (int i = 2; i <= value; ++i)
static double Combinations(int x, int y) {
return Factorial(x) / Factorial(y) / Factorial(x - y);
private static double Chances(int a, int t, int c) {
return Combinations(t, t - c + 1) *
Combinations(a - t, c - 1) /
public static void Main()
Console.WriteLine(Chances(40, 5, 2));