#include #include #include using namespace std; class Fibs { public: Fibs() { t.push_back(0); t.push_back(1); } int operator[]( int n ) { while ( n >= t.size() ) { t.push_back( t.rbegin()[0] + t.rbegin()[1] ); } return t[n-1]; } protected: vector t; }; int main( int argc, char** argv ) { istringstream src; src.str( argv[1] ); int n; src >> n; Fibs f; cout << f[n] << endl; }