Finding Fibonacci With Mathematical Formula in C
Join the DZone community and get the full member experience.
Join For FreeFinding Fibonacci sequence can be done by a simple logic, but here's a math formula. it can solve the case too.


int fibonaci(int n){
int i;float tmp;
//x^2 - x - 1 =0
float x1 = ( 1 + sqrt(5) ) / 2;
float x2 = (1 - sqrt(5) ) / 2;
for(i=0;i
Opinions expressed by DZone contributors are their own.
Comments