Skip to content

Instantly share code, notes, and snippets.

@michaelee
Created April 17, 2009 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelee/97141 to your computer and use it in GitHub Desktop.
Save michaelee/97141 to your computer and use it in GitHub Desktop.
int i = 1,
fact = 1;
// Invariant (fact == i!) is true here
while (i<N) {
i = i + 1;
fact = fact * i;
// Invariant (fact == i!) is true here
}
// We exit the above loop when i == N, so fact MUST contain N!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment