Skip to content

Instantly share code, notes, and snippets.

@leostera
Created August 27, 2011 18:10
Show Gist options
  • Save leostera/1175681 to your computer and use it in GitHub Desktop.
Save leostera/1175681 to your computer and use it in GitHub Desktop.
Factorial
#include <stdio.h>
int factorial(int a);
int main(int argc, char** argv)
{
int x;
scanf("%d",&x);
printf("%d", factorial(x));
return 0;
}
int factorial(int a)
{
int x = 1;
while(a > 0)
{
x = x*a;
--a;
}
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment