<?hh
function fibonacci(int $n): int {
/*
* Notice that in PHP, we do not have to declare our variables, nor must we
* declare their types. Also see how variables in PHP are prefaced with the
* dollar sign. Other than that, this is identical to the C version of this function.
*/
$a = 0;
$b = 1;
for ($i = 0; $i < $n; $i++){
printf("%d\n",$a);
$sum = $a+$b;
$a = $b;
$b = $sum;
}
}
fibonacci(1000);

eol versions

or quick preview in

Enable javascript to submit

You have javascript disabled. You will not be able to edit any code.

<?hh
function fibonacci(int $n): int {
/*
* Notice that in PHP, we do not have to declare our variables, nor must we
* declare their types. Also see how variables in PHP are prefaced with the
* dollar sign. Other than that, this is identical to the C version of this function.
*/
$a = 0;
$b = 1;
for ($i = 0; $i < $n; $i++){
printf("%d\n",$a);
$sum = $a+$b;
$a = $b;
$b = $sum;
}
}
fibonacci(1000);