posted 8 years ago
It completely depends on how you write your application. You can write a naive implementation that just defines the function similar to it's mathematical definition:
This however quickly results in a StackOverflowError. Instead, let's do some analysis on paper first. This is what I got:
Adding special cases for m <= 3 and memorizing results we've calculated before yields the following code:
This program finishes running almost instantly and if I comment out line 20 it prints the following results, which should give you an indication of the amount of memory it uses: