Here it is if you've ever wanted to have a class that creates them, and we all do, I just know it :-) This is a quick class I wrote while being bored, if anyone wants to make comments I'd welcome them. :-)

Code:#include <iostream> #include <cstdlib> #include <cmath> using namespace std; class Fibonacci { unsigned long *cache; int cache_max; public: explicit Fibonacci(int max = 46); ~Fibonacci(); int max(); unsigned long get(int); unsigned long operator[](int); }; Fibonacci::Fibonacci(int max) : cache_max(max + 1) { cache = new(nothrow) unsigned long[cache_max]; if (cache == 0) { cerr<<"No memory"<<endl; exit(1); } for (int i = 0; i < cache_max; i++) { cache[i] = 0; } } Fibonacci::~Fibonacci() { delete cache; } int Fibonacci::max() { return cache_max; } unsigned long Fibonacci::get(int n) { if (n > cache_max || n < 0) { cerr<<"Subscript out of range"<<endl; return 0; } else if (cache[n] == 0) { double s = sqrt(5.0); double x = 0.5 * s; // Deep magic cache[n] = ((pow(0.5 + x, n)) - (pow(0.5 - x, n))) / s; } return cache[n]; } unsigned long Fibonacci::operator[](int sub) { return get(sub); } int main() { Fibonacci fib; for (int i = 0; i < fib.max(); i++) { cout<< fib[i] <<endl; } }