the-honk/c/calculators/ncr.c
2024-10-09 18:02:37 +01:00

20 lines
321 B
C

#include <stdio.h>
#include "helpers/factorial.c"
int nCr(int n, int r) {
return factorial(n) / factorial(r) * factorial(n - r);
}
void main() {
int n;
int r;
printf("Please enter n: ");
scanf("%i", &n);
printf("Please enter r: ");
scanf("%i", &r);
int ans = nCr(n, r);
printf("The answer is: %i", ans);
}