From 166e12f9a85e781178dac40a56a27d95d806c2cb Mon Sep 17 00:00:00 2001 From: Ulriche Nguefack Date: Mon, 5 Feb 2024 22:01:49 +0100 Subject: [PATCH] permutation and combination called --- src/main/c/Calculator/calculator.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 99894eb..6f0a91d 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -250,3 +250,14 @@ double cosine(double angle) { double tangent(double angle) { return tan(angle * M_PI / 180.0); } +double permutation(int n, int r) { + int 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); +} \ No newline at end of file