diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-08-11 22:41:34 +0200 |
| commit | 1879caa1dd80cb11dd62403663917ad4bf7cc68e (patch) | |
| tree | ea41c6dd83a9f9bbfe0a891237674342de92d533 /wip/53-combinatoric-selections.c | |
| parent | 6b16d921543a62d880171791d39bcc58560785fa (diff) | |
| download | project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.gz project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.bz2 project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.zip | |
rename all file with 3 zero padding
Diffstat (limited to 'wip/53-combinatoric-selections.c')
| -rw-r--r-- | wip/53-combinatoric-selections.c | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/wip/53-combinatoric-selections.c b/wip/53-combinatoric-selections.c deleted file mode 100644 index 9006f5a..0000000 --- a/wip/53-combinatoric-selections.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - - -typedef long long unsigned int Natural; - -Natural factorial(Natural n) -{ - if (n == 1 || n == 0) return 1; - else return n * factorial(n - 1); -} - -Natural combination(Natural n, Natural r) -{ - if (r > n) exit(1); - Natural num = 0; - /* for (Natural i = 0; i < r - 1; i++) */ - /* num *= n - i; */ - /* return num / factorial(r); */ - /* if (factorial(r) * factorial(n - r) == 0) return 0; */ - return (factorial(n) / (factorial(r) * factorial(n - r))); - /* return (factorial(r) * factorial(n - r)); */ -} - -int main(void) -{ - printf("10! = %llu\n", factorial(10)); - printf("23! = %llu\n", factorial(23)); - printf("(23 - 10)! = %llu\n", factorial(23 - 10)); - int counter = 0; - Natural comb = 0, n, r; - /* for (n = 1; n <= 24; n++) */ - /* for (r = 1; r <= n; r++) { */ - /* comb = combination(n, r); */ - /* if (comb > 1000000) { */ - /* counter++; */ - /* comb = combination(23, 10); */ - printf("%llu C %llu = %llu\n", n, r, comb); - /* } */ - /* } */ - printf("counter = %d", counter); - return 0; -} |
