Skip to content

Instantly share code, notes, and snippets.

@RodriAndreotti
Created November 27, 2016 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RodriAndreotti/fe174c1150c7fa2fa1229f32717f9e7b to your computer and use it in GitHub Desktop.
Save RodriAndreotti/fe174c1150c7fa2fa1229f32717f9e7b to your computer and use it in GitHub Desktop.
Sequência de Fibonacci
<?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