Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: fibonacci.cpp // Compute the first n Fibonacci numbers #include // POST: return value is the n-th Fibonacci number F_n unsigned int fib (unsigned int n) { if (n == 0) return 0; if (n == 1) return 1; return fib(n-1) + fib(n-2); // n > 1 } int main() { std::cout << "Compute the first n Fibonacci numbers for n =? "; unsigned int n; std::cin >> n; for (unsigned int i=0; i