//program to get series 0,1,1,2,3,5,8....15th
term.

#include<conio.h>

void
main()

{

int i=0,j=1,n,k;

{

int i=0,j=1,n,k;

printf("%d\n",i);

printf("%d\n",j);

printf("enter nth number for 'n'\n");

scanf("%f",&n);

scanf("%f",&n);

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

{

{

k=i+j;

printf( "%d\n",k);

i=j;

j=k;

}

getch();

}

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

}

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

**logics in mind:**
->take two initial numbers as 'i' and 'j' for first two values '0' and '1'. If you want then you can input these numbers and display them.

->since we need to display 15th terms so we input 15 or 16 for variable 'n'. We can also fix it inside loop.

->Fibonacci series is that where we get terms by adding two previous terms.

->We have displayed first two terms (0 and 1). now we need to display only 13th terms.

->We display that using loop.

->inside loop, we get next term by adding fist two terms (look above).

->we display that.

->now we assign value of 'j' to 'i' and 'k' to 'j'. it works and goes on working for next cycle/iteration

## No comments:

## Post a Comment