Step5: Solve "eyeballs" for x, substitute into POST.
int factorial(int x) { int f, y; // PRE-CONDITION: x >= 0 y = 1; // y = 1 f = 1; // y = 1 and f = 1 while (y <= x) { f = f * y; y = y + 1; } // end while // INVARIANT: y <= x + 1 and EXIT: y > x // y = x + 1 // => x = y - 1 // POST-CONDITION: f = x! // => f = (y - 1)! // WARNING: This does not always work (what about zero?). Be careful. return f; }