Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise19.cpp
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--Week13/Exercise19.cpp16
diff --git a/Week13/Exercise19.cpp b/Week13/Exercise19.cpp
new file mode 100644
index 0000000..a0d5ace
--- /dev/null
+++ b/Week13/Exercise19.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+unsigned binom(unsigned n, unsigned k) {
+ if (k == 0 || n == k)
+ return 1;
+ return binom(n - 1, k - 1) + binom(n - 1, k);
+}
+
+int main() {
+ unsigned n, k;
+ std::cin >> n >> k;
+
+ std::cout << binom(n, k) << std::endl;
+
+ return 0;
+}