If you use an iterative / tail-recursive version you can actually do this directly, without even the overhead of having to calculate it twice.
(I.e. define fib to return a tuple / struct / etc consisting of (fib(n), fib(n-1)).)
That has been done millions of times over the past 800 odd years. My method has no practical uses, but plenty of educational ones.
If you use an iterative / tail-recursive version you can actually do this directly, without even the overhead of having to calculate it twice.
(I.e. define fib to return a tuple / struct / etc consisting of (fib(n), fib(n-1)).)