#include // file: fact.cc // author Dietolf Ramm; date: 11/10/96 // illustrate recursion with factorial computation int Fact(int n) // precondiont: n a non-negative (smallish) integer // postcondition: returns n! { if (n == 0) { return 1; } return n * Fact(n - 1); } int main() { int nfact, k = 0; do { nfact = Fact(k); cout << k << " " << nfact << endl; k++; } while ( nfact > 0); return 0; } Sample output: fact 0 1 1 1 2 2 3 6 4 24 5 120 6 720 7 5040 8 40320 9 362880 10 3628800 11 39916800 12 479001600 13 1932053504 14 1278945280 15 2004310016 16 2004189184 17 -288522240