Friday, 23 September 2016

Fibonacci by Recursion

/* Fibonacci by Recursion */

#include<stdio.h>
int fib(int);

int main()
{
printf("Type any value : ");
printf("\nNth value: %d",fib(getche()-'0'));
return 0;
}

int fib(int n)
{
if(n<=1)
return n;
return(fib(n-1)+fib(n-2));
}

No comments:

Post a Comment

Featured post

Country State City Database - MySQL / JSON Download

World Data Bundle — Full Continent, Country, State, City & Currency Dataset This article provides an overview of the  World Geo Data  di...