1
0
Fork 0

Problem 53

This commit is contained in:
Jonathan Chan 2016-12-23 17:34:44 -08:00
parent fbc3aa7e4f
commit 0d4491d68a
2 changed files with 27 additions and 0 deletions

BIN
53 Executable file

Binary file not shown.

27
53.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
long long choose (int n, int r) {
long long numerator = 1;
long long denominator = 1;
for (int i = 1; i <= r; i++) {
numerator *= n + 1 - i;
denominator *= i;
}
printf ("%d choose %d = %lli\n", n, r, numerator/denominator);
return numerator / denominator;
}
int main () {
int count = 4;
int n = 24;
int r = 10;
while (n <= 100) {
while (choose (n, r-1) > 1000000)
r--;
count += n - 2*r + 1;
n++;
}
printf ("Final r: %d; count: %d\n", r, count);
}