public void Combination() { var factor = new StaticModIntFactor <Mod1000000007>(10); for (int i = 0; i <= 10; i++) { for (int j = 0; j <= 10; j++) { factor.Combination(i, j).Value.Should().Be((int)MathLibEx.Combination(i, j)); } } factor.Invoking(factor => factor.Combination(11, 0)).Should().Throw <Exception>(); }
public void Combination() { for (int i = 0; i <= 10; i++) { for (int j = 0; j <= i; j++) { long n = 1, d = 1; for (int k = 0; k < j; k++) { n *= i - k; d *= k + 1; } MathLibEx.Combination(i, j).Should().Be(n / d); } } }