Browse Source

refactoring: ending-permutation|combination

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
d8e8de918d
  1. 11
      src/main/c/Calculator/calculator.c

11
src/main/c/Calculator/calculator.c

@ -128,6 +128,17 @@ double factorial(double num) {
return num * factorial(num - 1); return num * factorial(num - 1);
} }
} }
double permutation(int n, int r) {
double result = 1;
for (int i = 0; i < r; i++) {
result *= (n - i);
}
return result;
}
double combination(int n, int r) {
return permutation(n, r) / factorial(r);
}
int getIntInput(const char *message) { int getIntInput(const char *message) {
int input; int input;

Loading…
Cancel
Save