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