Skip to content

Instantly share code, notes, and snippets.

@jarnheimer
Last active August 6, 2019 15:16
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 jarnheimer/e5f0864662dbb14cdcaf8678387ec29a to your computer and use it in GitHub Desktop.
Save jarnheimer/e5f0864662dbb14cdcaf8678387ec29a to your computer and use it in GitHub Desktop.
Refactor Fibonacci
<?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';
}
}
@jarnheimer
Copy link
Author

Read more about this here :)
https://en.wikipedia.org/wiki/Fibonacci_number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment