Nov-24-2018, 03:55 AM
You are making the same calculations over and over again. Say you try fib(5). That's fib(4) + fib(3). But those are fib(3) + fib(2) + fib(2) + fib(1). So far you've called fib(3) and fib(2) twice each. It would be faster to just generate the numbers until you have n of them. Now, if you have to pass multiple tests, I would save the numbers you calculate for the first test, so you don't have to calculate them again.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures