diff --git a/src/calculateFactorial.c b/src/calculateFactorial.c new file mode 100644 index 0000000..adb19d0 --- /dev/null +++ b/src/calculateFactorial.c @@ -0,0 +1,19 @@ + + +#include "calculateFactorial.h" + +int calculateFactorial_integer(int n) { + if (n < 0) { + + } else if (n == 0 || n == 1) { + + return 1; + } else { + + int result = 1; + for (int i = 2; i <= n; ++i) { + result *= i; + } + return result; + } +} diff --git a/src/calculateFactorial.h b/src/calculateFactorial.h new file mode 100644 index 0000000..f48849b --- /dev/null +++ b/src/calculateFactorial.h @@ -0,0 +1,8 @@ + + +#ifndef THEADMIRALS_CALCULATEFACTORIAL_H +#define THEADMIRALS_CALCULATEFACTORIAL_H + +int calculateFactorial_integer(int n); + +#endif //THEADMIRALS_CALCULATEFACTORIAL_H