Skip to content

Instantly share code, notes, and snippets.

@lucablackwell
Created July 21, 2022 10:55
Show Gist options
  • Save lucablackwell/b8bc343ee526e4ea85072d55051e2419 to your computer and use it in GitHub Desktop.
Save lucablackwell/b8bc343ee526e4ea85072d55051e2419 to your computer and use it in GitHub Desktop.
<?php
function Fibonacci($number){
if ($number == 0)
return 0;
else if ($number == 1)
return 1;
else
return (Fibonacci($number-1) +
Fibonacci($number-2));
}
$number = 1000;
for ($counter = 0; $counter < $number; $counter++){
$start = time();
echo (strlen($counter) == 1 ? '0' . $counter : $counter) . ": " . Fibonacci($counter) . " (" . (time() - $start) . ")\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment