Math.Combination("5","3");
5!/[3!x(5-3)] | 120/[6.(2)] ->
10
nCk
5C3 = 5!/[3!(5-3)!]=10
1 2 3 4 5 6 7 8 9 10 11 12 | /// <summary> /// https://groophy-inc.github.io/combination /// </summary> /// <param name="n"></param> /// <param name="k"></param> /// <returns></returns> public static GValue Combination(GValue n, GValue k) { GValue ret = Division(Factorial(n), Multiplication(Factorial(k), Factorial(Subtraction(n, k)))); ret.get_String = (Factorial(n).ToString() + "/[" + Factorial(k).ToString() + ".("+Factorial(Subtraction(n, k).ToString()).ToString()+")] = " + ret.get_Decimal.ToString()); return ret; } |
Copyright © Groophy.Inc ' Batch-Man