示例#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))));
 }
示例#2
0
 /**
  * This method tests the "fibonacci" method.
  *
  * @dataProvider data_fibonacci
  */
 public function test_fibonacci(array $provided, array $expected)
 {
     $p0 = IInt32\Module::fibonacci(IInt32\Type::box($provided[0]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0);
     $this->assertEquals($e0, $p0->unbox());
 }