Created
August 24, 2015 13:37
-
-
Save gut/9b593d335445df0b04cd to your computer and use it in GitHub Desktop.
Simple PHP 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 | |
$n = 90; // Input: calculate fibonacci of 90 | |
$f1 = -1; | |
$f2 = 1; | |
for ($i = 1; $i <= $n; $i++) { | |
$f = $f1 + $f2; | |
$f1 = $f2; | |
$f2 = $f; | |
} | |
echo $f; // output: result of fibonacci of 90 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment