Application of fibo function!

How much time would it take to fibo function to calculate
fibo (100)? Why? and thank you in advance.
here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "/home/src/prog.hpp"
unsigned fibo(unsigned n) {
return n<=2?1:fibo(n-1)+fibo(n-2);
}

unsigned n;

int main(int argc, char* argv[]) {
if(argc != 2) { 
cout<<argv[0]<<":syntax error, incorrect number of arguments\n";
exit(1);
}
n = atoi(argv[1]); 
cout<<"fibo("<<n<<")=" << fibo(n)<<endl;
return 0;
}
Hi,

Try Googleing Big O notation for fibonacci, and read the wiki page for the same.

Why don't you try with smaller numbers first?

Brute force often isn't the answer here, one needs to come up with a cunning plan :+)

Cheers :+)
hi,
I think recursion is wrong to calculate the Fibonacci function I like to know why the computer takes a long time to evaluate fibo 100 !! please
Topic archived. No new replies allowed.