Skip to content

Instantly share code, notes, and snippets.

@madson
Created October 21, 2011 17:22
Show Gist options
  • Save madson/1304396 to your computer and use it in GitHub Desktop.
Save madson/1304396 to your computer and use it in GitHub Desktop.
Factorial calc with C
#include <stdio.h>
int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n-1);
}
int main() {
int number = 5;
int result = factorial(number);
printf("The factorial number of %i is %i!", number, result);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment