It's preferable to simply use "break;" where you have "goto end;"
The suffix for unsigned long long is "ULL", not "LL".
Functions do not need a semicolon at the end of their scope-finishing brace.
Since you're new to recursion, you may not quite understand why it starts to get slow around 36. May I suggest adding a simple:
Code: Select all
std::cout << "Input: " << input << std::endl;
...to the beginning of your fibo function? It will make it very clear just how many calls you're doing.
...
Except that won't work. Go ahead and try it, and you'll realize that you'll never finish. Printing that many values would take a very, very long time.
Instead, make a global unsigned called "calls", initialize it to 0, and "++calls;" at the beginning of your function. Then, once it's done, print out its value.
You've now seen first-hand why people invented
memoization.