#include "library.h" const int limit = 50; int answers[limit + 1]; int fib(const int n) { if (answers[n] != -1) return answers[n]; if (n <= 2) return 1; const int a = fib(n-1); const int b = fib(n-2); answers[n] = a+b; return a+b; } void blank_array(int A[], const int size) { int x = 0; while (x < size) { A[x] = -1; x = x + 1; } } void main() { blank_array(answers, limit); int x = 1; while (x < limit) { cout << "fib(" << x << ") = " << fib(x) << "\n"; x = x + 1; } }