Browse Source

calculate Factorial function added

remotes/origin/develop
Leon Wolf 11 months ago
parent
commit
5fd80942f4
  1. 19
      src/calculateFactorial.c
  2. 8
      src/calculateFactorial.h

19
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;
}
}

8
src/calculateFactorial.h

@ -0,0 +1,8 @@
#ifndef THEADMIRALS_CALCULATEFACTORIAL_H
#define THEADMIRALS_CALCULATEFACTORIAL_H
int calculateFactorial_integer(int n);
#endif //THEADMIRALS_CALCULATEFACTORIAL_H
Loading…
Cancel
Save