Created
July 30, 2013 02:49
-
-
Save dafyddcrosby/6109785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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