Last active
August 6, 2019 15:16
-
-
Save jarnheimer/e5f0864662dbb14cdcaf8678387ec29a to your computer and use it in GitHub Desktop.
Refactor 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 | |
function fibonacci(int $n) | |
{ | |
if ($n < 50) { | |
if ($n !== 0) { | |
if ($n !== 1) { | |
return fibonacci($n - 1) + fibonacci($n - 2); | |
} else { | |
return 1; | |
} | |
} else { | |
return 0; | |
} | |
} else { | |
return 'Not supported'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read more about this here :)
https://en.wikipedia.org/wiki/Fibonacci_number