Created
October 28, 2015 08:54
-
-
Save ischenkodv/34baee481a95da808cb7 to your computer and use it in GitHub Desktop.
Fibonacci function
This file contains hidden or 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
function fibonacci($n) { | |
if (is_int($n)) { | |
return round(pow((sqrt(5)+1)/2, $n) / sqrt(5)); | |
} else { | |
throw new Exception('Value should be an integer'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment