<?php function findFib($n) { $fib = []; for($i=3, $fib[1]=0, $fib[2]=1; $i<=$n; $i++) { $fib[$i] = $fib[$i-1] + $fib[$i-2]; } return $fib; } $a = []; $a = findFib(10);
Standard input is empty
Array ( [1] => 0 [2] => 1 [3] => 1 [4] => 2 [5] => 3 [6] => 5 [7] => 8 [8] => 13 [9] => 21 [10] => 34 )