#include #include "prompt.h" using namespace std; // illustrates loop and integer overflow long Factorial(int num); int main() { int highValue = PromptRange("enter max value for factorial",1,30); int current = 0; // compute factorial of this value while (current <= highValue) { cout << current << "! = " << Factorial(current) << endl; current += 1; } return 0; } long Factorial(int num) // precondition: num >= 0 // postcondition returns num! { long product = 1; int count = 0; while (count < num) // invariant: product == count! { count += 1; product *= count; } return product; }