src/Zoya/Coin/Fibonacci.php
public function fib($n)
    {
        if ($n < 3) return 1;
        $k = $n / 2;
        $a = $this->fib($k + 1);
        $b = $this->fib($k);
        if ($n % 2 == 1) {
            return $a * $a + $b * $b;
        } else {
            return $b * (2 * $a - $b);
        }
    }
public function fib($n)
    {
        if ($n < 3) return 1;
        $k = $n / 2;
        $a = $this->fib($k + 1);
        $b = $this->fib($k);
        if ($n % 2 == 1) {
            return $a * $a + $b * $b;
        } else {
            return $b * (2 * $a - $b);
        }
    }
public function fib ( $ n ) { if ( $ n < 3 ) return 1 ; $ k = $ n / 2 ; $ a = $ this -> fib ( $ k + 1 ) ; $ b = $ this -> fib ( $ k ) ; if ( $ n % 2 == 1 ) { return $ a * $ a + $ b * $ b ; } else { return $ b * ( 2 * $ a - $ b ) ; } }
Returns n'th Fibonacci number
@see https://en.wikipedia.org/wiki/Fibonacci_number
@param $n
@return int
Returns n th Fibonacci number