Created
February 10, 2014 04:55
-
-
Save greycode/8910574 to your computer and use it in GitHub Desktop.
计算第N个斐波那契数
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 nthFibo(n) { | |
var Phi = (1 + Math.sqrt(5))/ 2; | |
return Math.round ((Math.pow(Phi, (n-1)) - Math.pow(Phi*-1, (n-1)*-1)) / Math.sqrt(5)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment