Last active
August 29, 2015 14:06
-
-
Save marcmascort/b8601a037f7e41ca8f6f to your computer and use it in GitHub Desktop.
Get the Fibonacci N number
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($n=0) | |
{ | |
$n = abs(intval($n)); | |
return ($n===0) ? 0 : ( ($n === 1 || $n === 2) ? 1 : ( fibonacci($n - 1) + fibonacci($n - 2) ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment