The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
- The next number is found by adding up the two numbers before it.
- The 2 is found by adding the two numbers before it (1+1)
- Similarly, the 3 is found by adding the two numbers before it (1+2),
- And the 5 is (2+3),
- and so on!
#include<stdio.h>
#include<conio.h>
int n1=0,n2=1,t,i,n;
void main()
{
printf("Enter How many numbers you want to display: ");
scanf("%d",&n);
printf("%d\t%d\t",n1,n2);
for(i=1;i<=n-2;i++)
{
t=n1+n2;
printf("%d\t",t);
n1=n2;
n2=t;
}
getch();
No comments:
Post a Comment