INTRODUCING 5 - days-a-week problem solving session for Math Olympiad and ISI Entrance. Learn More

We all know about the famous Fibonacci (was the name given to Leonardo Pisano) Series . In this series each number is the sum of the two preceding ones, starting from 0 and 1. That is \(F_0\)=0 and \(F_1\)=1

and

\(F_n\)=\(F_{n−1}\)+\(F_{n−2}\) for n>1

In some old books \(F_0\) is omitted and the the entire things starts with \(F_1\)and \(F_2\)that is \(F_1\)=\(F_2\)=1

so it starts like this 0,1,1,2,3,5,8,13,……..

Now in order to find the 30th term of the above mentioned series we write a program in C and that is

`#include <stdio.h>`

`Void main ()`

`{`

**long****int**i, n, t1 = 0, t2 = 1, nextTerm;`printf("Enter the number of terms: ");`

`scanf("%li", &n);`

`printf("Fibonacci Series: ");`

**for**(i = 1; i <= n; ++i)`{`

`printf("%d, ", t1);`

`nextTerm = t1 + t2;`

`t1 = t2;`

`t2 = nextTerm;`

`}`

`}`

After compiling the above program in C , we enter the value of ?n as 30 and the output is

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,5142290,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

Here 514229 is the 30th term of the Fibonacci Series

Advanced Mathematical Science. Taught by olympians, researchers and true masters of the subject.

JOIN TRIAL
Google