Fibonacci function by using simple recursive approach, C/C++ Programming

Implement, in rPeANUt, the a Fibonacci function by using the simple recursive approach. The Fibonacci function can be implemented in c as follow:

int fib(int x) {

  if (x<2) {

    return x;

  } else {

    return fib(x-1) + fib(x-2);

  }

}

Test your implementation (e.g. fib(5) == 5, fib(7) == 13, fib(8) == 21)? What is the biggest Fibonacci number you can calculate in under about 1min of execution time?

 

 

Posted Date: 3/8/2013 6:24:10 AM | Location : United States







Related Discussions:- Fibonacci function by using simple recursive approach, Assignment Help, Ask Question on Fibonacci function by using simple recursive approach, Get Answer, Expert's Help, Fibonacci function by using simple recursive approach Discussions

Write discussion on Fibonacci function by using simple recursive approach
Your posts are moderated
Related Questions
Write a function that calculates the number of elapsed days between two dates. For example the days between Feb 3, 1970 and June 21, 1980? Becareful for the Leap year.

Write a recursive function recursiveMin that takes an integer array, a starting subscript and an ending subscript as arguments, and returns the smallest element in the array. The f

Differentiate between the expression "++a" and "a++"? - With ++a, increment happens first on variable a, and resulting value is used. This is known as prefix increment. - Wi

Program is to read the characters from keyboard: Program is to read the characters from keyboard one by one stored in different files as upper constants, lower constants, othe


In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

WAP TO PRINT SERIES FROM 1 TO 10 & FIND ITS SQUARE AND CUBE # include stdio.h> # include conio.h> # include math.h>   void main () { int a=1,sqr=0,cube=0;

Although we can handle most I/O routines with getc and putc , there are file versions of fgets, fputs, fprintf and fscanf . The syntax is       fgets(stringname,n,filename);   Th

write a program to calculate gross salary and net salary using hra da pf in c++

Arguments Passing Mechanism C++ supports the following argument passing mechanisms: i).  Pass by value: A copy of the arguments value is made and passed to the called functio