Exemplo n.º 1
0
 /**
  * This method computes the nth fibonacci number.
  *
  * @access public
  * @static
  * @param IInt32\Type $n                                    the operand
  * @return IInt32\Type                                      the result
  */
 public static function fibonacci(IInt32\Type $n) : IInt32\Type
 {
     return IInt32\Module::le($n, IInt32\Type::one())->unbox() ? $n : IInt32\Module::add(IInt32\Module::fibonacci(IInt32\Module::decrement($n)), IInt32\Module::fibonacci(IInt32\Module::subtract($n, IInt32\Type::box(2))));
 }
Exemplo n.º 2
0
 /**
  * This method tests the "subtract" method.
  *
  * @dataProvider data_subtract
  */
 public function test_subtract(array $provided, array $expected)
 {
     $p0 = IInt32\Module::subtract(IInt32\Type::box($provided[0]), IInt32\Type::box($provided[1]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0);
     $this->assertEquals($e0, $p0->unbox());
 }