Created
July 21, 2022 10:55
-
-
Save lucablackwell/b8bc343ee526e4ea85072d55051e2419 to your computer and use it in GitHub Desktop.
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 | |
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