C Program to Display Fibonacci Series Using While Loop: Fibonacci series is a series of numbers in which each number of the Fibonacci series is derived by the adding of its two immediate preceding numbers.Fibonacci sequence is one of the most famous formulas in mathematics.
C Program to Display Fibonacci Series Using While Loop
#include<stdio.h>
int main()
{
int n,i,a,b,c;
printf("Enter a Number: ");
scanf("%d",&n);
i=1;
a=0;
b=1;
while(i<=n)
{
printf("%d ",a);
c = a + b;
a = b;
b = c;
i++;
}
return 0;
}
Output of Program
Enter a Number: 40
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986