the-honk/c/calculators/ncr.c

21 lines
321 B
C
Raw Normal View History

2024-10-09 17:02:36 +00:00
#include <stdio.h>
2024-10-09 17:02:37 +00:00
#include "helpers/factorial.c"
2024-10-09 17:02:36 +00:00
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);
}