#include const bool debug = true; /* do I want to print debugging info? */ int product(unsigned int n) { /* debugging: print args */ if (debug) cout << "n (product): " << n << endl; int total; while (n > 0) { /* debugging: print loop vars */ if (debug) cout << "n,total (loop top): " << n << " " << total << endl; n = n-1; total = total*n; /* debugging: print loop vars (and on last iteration, the result) */ if (debug) cout << "n,total (loop bottom): " << n << " " << total << endl; } return total; } int main() { unsigned int n; cin >> n; cout << product(n) << endl; /* print 1*...*n */ }