Skip to content

Instantly share code, notes, and snippets.

@GuangchuangYu
Created February 9, 2012 05:32
Show Gist options
  • Save GuangchuangYu/1777607 to your computer and use it in GitHub Desktop.
Save GuangchuangYu/1777607 to your computer and use it in GitHub Desktop.
calculating fibonacci number
fibonacci <- function(n) {
u <- (1+sqrt(5))/2
(u^n - (1-u)^n) / sqrt(5)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment