Skip to content

Instantly share code, notes, and snippets.

@gut
Created August 24, 2015 13:37
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 gut/9b593d335445df0b04cd to your computer and use it in GitHub Desktop.
Save gut/9b593d335445df0b04cd to your computer and use it in GitHub Desktop.
Simple PHP fibonacci
<?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