Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- big fib_with_memo(int n) {
- static int most_recent_addition_index = 1;
- static std::vector<big> mem = {0, 1};
- if (most_recent_addition_index < n) {
- big val = fib_with_memo(n-1) + fib_with_memo(n-2);
- mem.push_back(val);
- most_recent_addition_index++;
- return val;
- }
- return mem[n];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement