Exemple #1
0
 /**
  * This method computes the nth factorial number.
  *
  * @access public
  * @static
  * @param IInt32\Type $n                                    the operand
  * @return IInt32\Type                                      the result
  */
 public static function factorial(IInt32\Type $n) : IInt32\Type
 {
     return IInt32\Module::eq($n, IInt32\Type::zero())->unbox() ? IInt32\Type::one() : IInt32\Module::multiply($n, IInt32\Module::factorial(IInt32\Module::decrement($n)));
 }
 /**
  * This method tests the "factorial" method.
  *
  * @dataProvider data_factorial
  */
 public function test_factorial(array $provided, array $expected)
 {
     $p0 = IInt32\Module::factorial(IInt32\Type::box($provided[0]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0);
     $this->assertEquals($e0, $p0->unbox());
 }