Fibonacci Series in C

 What is a Fibonacci series?

In mathematics, the Fibonacci series, commonly denoted by Fn, form the sequence, the Fibonacci sequence in which each number is the sum of two preceding ones. The sequence commonly starts from 0 and 1.

    F0 =  0   , F1 =1 

  Fn = Fn-1+ Fn-2 where n>1


F2= F1+F0

    =0+1=1

F3=F2+F1=1+1=2

F4=2+1=3

F5=3+2=5

F6=5+3=8

-----------------------------------------------------------------------------------------------------------------------------------------------------

Write a c program to generate Fibonacci series?

#include<stdio.h>

#include<conio.h>

int main()

{

int n,i,f0=0,f1=1,temp=1;

    printf("Enter the Size of Fibonacci Series");

    scanf("%d",&n);

    printf("0 \t");

    for(i=1;i<n;i++)

{

        printf("%d \t",temp);

        temp=f1+f0;

       f0=f1;

      f1=temp;

  }

     return 0;

}

----------------------------------------------------------------------------------------------------------------------------------------------------online c compiler   


Output: 



Comments

Popular posts from this blog

Write a query to practice in Northwind database

How to write an email for last day in office