Created
March 17, 2017 07:15
-
-
Save uyab/3bbc2f674d73d1cc139513f4845c081d to your computer and use it in GitHub Desktop.
Deret 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 | |
// 0,1,1,2,3,5,8,13 | |
$fib = []; | |
foreach (range(0, 100) as $i) { | |
if ($i == 0) { | |
$fib[$i] = 0; | |
} elseif ($i == 1) { | |
$fib[$i] = 1; | |
} else { | |
$fib[$i] = $fib[$i - 2] + $fib[$i - 1]; | |
} | |
} | |
echo implode('<br>', $fib); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment