Skip to content

Instantly share code, notes, and snippets.

@dafyddcrosby
Created July 30, 2013 02:49
Show Gist options
  • Save dafyddcrosby/6109785 to your computer and use it in GitHub Desktop.
Save dafyddcrosby/6109785 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int factorial (int n) {
int i = 1;
while (n > 1) {
i *= n;
n -= 1;
}
return i;
}
int main (int argc, char *argv[]) {
int fac4 = factorial(4);
int fac5 = factorial(5);
printf("4! = %d, 5! = %d\n", fac4, fac5);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment