예제 #1
0
<?php

class Fibonacci
{
    private $f = array(0, 1, 1);
    public function get($n)
    {
        if (!isset($this->f[$n])) {
            $this->f[$n] = $this->get($n - 1) + $this->get($n - 2);
        }
        return $this->f[$n];
    }
}
$fibonacciNumbers = new Fibonacci();
foreach (file($argv[1]) as $line) {
    echo $fibonacciNumbers->get(trim($line)) . "\n";
}
예제 #2
0
 /**
  * @expectedException        InvalidArgumentException
  * @expectedExceptionMessage Application only accepts integers. Input was: string
  */
 public function testInvalidArgumentNotInteger()
 {
     Fibonacci::get("string");
 }