/**
  * Axiom: L(n,2) = (n - 1)n! / 2
  * Lah number identity when k is 2
  *
  * @dataProvider dataProivderForLahNumberIdentities
  */
 public function testLahNumberIdentityKEqualsTwo(int $n)
 {
     // Skip exception where n < k
     if ($n === 1) {
         return;
     }
     $L⟮n、1⟯ = Combinatorics::lahNumber($n, 2);
     $⟮n−1⟯n!/2 = ($n - 1) * Combinatorics::factorial($n) / 2;
     $this->assertEquals($L⟮n、1⟯, $⟮n−1⟯n!/2);
 }
예제 #2
0
 public function testFactorialBoundsException()
 {
     $this->setExpectedException('MathPHP\\Exception\\OutOfBoundsException');
     Combinatorics::factorial(-1);
 }