Created
November 27, 2016 21:35
-
-
Save RodriAndreotti/fe174c1150c7fa2fa1229f32717f9e7b to your computer and use it in GitHub Desktop.
Sequência de Fibonacci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fib = array(); | |
for($i = 0; $i < 10; $i++){ | |
if($i < 2){ | |
$fib[$i] = $i; | |
} else { | |
$fib[$i] = $fib[$i - 1] + $fib[$i-2]; | |
} | |
} | |
foreach($fib as $key => $f){ | |
$coma = ''; | |
if($key > 0){ | |
$coma = ', '; | |
} | |
echo $coma . $f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment