Skip to content

Instantly share code, notes, and snippets.

@greycode
Created February 10, 2014 04:55
Show Gist options
  • Save greycode/8910574 to your computer and use it in GitHub Desktop.
Save greycode/8910574 to your computer and use it in GitHub Desktop.
计算第N个斐波那契数
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