Over a million developers have joined DZone.

Finding Fibonacci With Mathematical Formula in C

DZone's Guide to

Finding Fibonacci With Mathematical Formula in C

Free Resource

Finding Fibonacci sequence can be done by a simple logic, but here's a math formula. it can solve the case too. 

The formula :  Fn = (x1^n – x2^n) / root(5)  dengan pembulatan kebawah
    where X1 and X2 are the roots of    x^2  - x - 1=0  equation      
   to find  X1 and X2 , we can use the following formula
   So that  X1,X2  =>    
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;  

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}