Skip to content

Instantly share code, notes, and snippets.

@MaheshReddy
Created June 10, 2014 20:37
Show Gist options
  • Save MaheshReddy/101a1a03b98849a4ada8 to your computer and use it in GitHub Desktop.
Save MaheshReddy/101a1a03b98849a4ada8 to your computer and use it in GitHub Desktop.
simple function to generate Fibonacci series.
float golden_ratio = 1.61803398874989484820;
float root_5 = 2.2360679774997896964091736687313;
int get_fibonacci(int n){
float fib_num = 0.0;
fib_num = (powf(golden_ratio,(float)n) - powf(1 - golden_ratio,(float)n)) / root_5;
return (int)fib_num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment