diff --git a/Algorithms/Maths/factorial/factorial.c b/Algorithms/Maths/factorial/factorial.c new file mode 100644 index 00000000..b6c0e113 --- /dev/null +++ b/Algorithms/Maths/factorial/factorial.c @@ -0,0 +1,21 @@ +#include + +int factorial(int n) +{ + int result; + + if (0 == n) { + result = 1; + } else { + result = n * factorial(n - 1); + } + + return result; +} + +int main(int argc, char **argv) +{ + printf("The factorial of 3 is: %d\n", factorial(3)); + + return 0; +}