Professional Documents
Culture Documents
Fibanocci Series Term
Fibanocci Series Term
Week-1
Write recursive program which computes the nth Fibonacci number, for appropriate values of
n. Analyze behavior of the program Obtain the frequency count of the statement for various
values of n.
The Fibonacci series 0, 1, 1, 2, 3, 5, 8, 13, 21, .. Begins with the terms 0 and 1
and has the property that each succeeding term is the sum of the two preceding
terms.
Algorithm steps:
1. Start.
2. Get the number n up to which Fibonacci series is generated.
3.Call to the function fib.
4.stop Algorithm fib
1.start
2.if n=0 or 1 then return n
3.else return fib(n-1)+fib(n-2)
4. Stop.
Program
/*
* C Program to find the nth number in Fibonacci series using recursion
*/
#include <stdio.h>
int fibo(int);
int main()
{
int num;
int result;
OUTPUT
Enter the nth number in fibonacci series: 5
The 5 number in fibonacci series is 5
Enter the nth number in fibonacci series: 6
The 6 number in fibonacci series is 8