18 lines
371 B
PHP
18 lines
371 B
PHP
<?php
|
|
|
|
function fibonacci(int $n) : int {
|
|
if ($n <= 1)
|
|
return $n;
|
|
return fibonacci($n - 1) + fibonacci($n - 2);
|
|
}
|
|
|
|
echo fibonacci(1).PHP_EOL;
|
|
echo fibonacci(2).PHP_EOL;
|
|
echo fibonacci(3).PHP_EOL;
|
|
echo fibonacci(4).PHP_EOL;
|
|
echo fibonacci(5).PHP_EOL;
|
|
echo fibonacci(6).PHP_EOL;
|
|
echo fibonacci(7).PHP_EOL;
|
|
echo fibonacci(8).PHP_EOL;
|
|
|
|
//1 1 2 3 5 8 13 21 34
|