[ create a new paste ] login | about

Link: http://codepad.org/pMKs4kvb    [ raw code | fork ]

C++, pasted on Mar 12:
// - Both these code return the same wrong value of 8?

// My code I got by myself

int FibiRec(int n){
	int result = 0;
	if (n == 0 || n == 1){
		return 1;
	}else{
		return FibiRec(n-1) + FibiRec(n-2);
	}
}

// Code I got from a number of other sources...

long fib(int n)
   {
   if (n<2)					      // stopping cases
      return 1;
   else                           // recursive case
      return fib(n - 1) + fib(n - 2);
   }

// What am I doing wrong?


Create a new paste based on this one


Comments: