Join 307,142 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,759 people online right now. Registration is fast and FREE... Join Now!
This function does not require a header file.
Besides, it is a code snippet and not a complete application. You will have to call it from main() or any other function to use it.
giotto 2008-02-04 08:59:49
Oh, come on!
It can be done, in one line!
int fibonacci(int number){
return number
giotto 2008-02-04 09:00:20
int fibonacci(int number){
return number
giotto 2008-02-04 09:00:49
:S
nurboja 2008-05-03 03:07:39
int fib(int x)
{
if (x==0) return 0;
else if (x==1) return 1;
else return fib(x-1)+fib(x-2);
}
nurboja 2008-05-03 03:08:04
Fn=0 za n= 0;
Fn=1 za n= 1;
Fn=Fn–1+ Fn–2 za n>=2;
yuyu89 2009-01-26 05:37:14
what is the header to run this codes
int fib(int x) { if (x==0) return 0; else if (x==1) return 1; else return fib(x-1)+fib(x-2); }
shabaaz 2009-04-15 12:47:40
also use "static int"for f1 and f2
shabaaz 2009-04-15 12:48:29
regular c header.....stdio.h
or iostream for c++
shida 2009-07-29 03:05:59
how can I write fibonacci with arrays?
autumn_storm2216 2009-08-07 04:29:40
what if x = 2 which in fibonacci is also 1.you just give the condition if x = 1?
Desafiante 2009-11-15 02:27:41
More examples of the Fibonacci sequence may be found here
http://talkbinary.com/programming/c/special-functions/fibonacci-in-c/