Skip to content

Instantly share code, notes, and snippets.

@marcmascort
Last active August 29, 2015 14:06
Show Gist options
  • Save marcmascort/b8601a037f7e41ca8f6f to your computer and use it in GitHub Desktop.
Save marcmascort/b8601a037f7e41ca8f6f to your computer and use it in GitHub Desktop.
Get the Fibonacci N number
<?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