chelout
function fibonacci_no_iteration($n)
{
return round(pow((sqrt(5)+1)/2, $n) / sqrt(5));
}
function fibonacci($n)
{
}
function fib1($n)
{
return $n < 3 ? 1 : fib1($n - 1) + fib1($n - 2);
}
function fib2($n, $c = 2, $n2 = 0, $n1 = 1)
{
return $c < $n ? fib2($n, $c + 1, $n1, $n1 + $n2) : $n1 + $n2;
}
$start = microtime(true);
dump(
fib1(10)
);
$end = microtime(true);
dump($end - $start);
55
0.039812088012695
=> 0.039812088012695