From d63786ed2b3ce09a267d13b068709e1ccca6b4ec Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Wed, 17 May 2023 12:42:01 +0100 Subject: [PATCH 01/11] Binominal calculate clean up FIX: altered the structure of if else if statements to have guard clauses first before main functionality, added brackets to make calculation steps more clear (Following BODMAS), updated namespaces used in file, removed unneeded user input code CHORE: Added explanations and other documentation --- math/binomial_calculate.cpp | 102 ++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index abfedca6256..a1697c71464 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -3,12 +3,30 @@ * @brief Program to calculate [Binomial * coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient) * + * @details + * quoted from: [Weisstein, Eric W. "Binomial Coefficient." From MathWorld--A + * Wolfram Web + * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The + * binomial coefficient [; meaning n above k in brackets, how binomial + * coefficients are notated] (n; k) is the number of ways of picking k unordered + * outcomes from n possibilities, also known as a combination or combinatorial + * number. The symbols [ _ representing subscript ] _nC_k and (n; k) are used to + * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) + * therefore gives the number of k-subsets possible out of a set of n distinct + * items. For example, The 2-subsets of {1,2,3,4} are the six pairs {1,2}, + * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so (4; 2)=6." [Another good + * example/explanation](https://math.stackexchange.com/questions/2172355/probability-notation-two-numbers-stacked-inside-brackets) + * + * @note An identity of the binomial coefficient is (n; n-k) This is explained + * partially in the comments of this implementation but in more detail at [Prof. + * Tesler: Chapter 3.3, 4.1, 4.3. Binomial Coefficient + * Identities](https://mathweb.ucsd.edu/~gptesler/184a/slides/184a_ch4slides_17-handout.pdf + * page 2) + * * @author [astronmax](https://github.com/astronmax) */ #include /// for assert -#include /// for int32_t type -#include /// for atoi #include /// for IO operations /** @@ -16,37 +34,46 @@ * @brief Mathematical algorithms */ namespace math { -/** - * @namespace binomial - * @brief Functions for [Binomial - * coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient) - * implementation - */ -namespace binomial { /** * @brief Function to calculate binomial coefficients - * @param n first value - * @param k second value - * @return binomial coefficient for n and k + * @param n number of possibilities + * @param k size of subset + * @return n if k == 1 + * @return 1 if k == 0 + * @return result if k != 0 || 1 */ size_t calculate(int32_t n, int32_t k) { - // basic cases - if (k > (n / 2)) - k = n - k; - if (k == 1) - return n; - if (k == 0) + /*! + * Why do we do if k > (n/2) then k = n-k? Because (n;k) is the same as + * (n;n-k) or, in this case, (6;4) is the same as (6;2) since both are + * calculated for n!/k!(n-k)! , in this case 6!/4!2! . By replacing k with + * n-k we get 6!/2!4! which is the same sum. the benefit however, is our + * loop further on in this implementation now requires less iterations to + * find the same answer. + * + * k == 1 and k == 0 follow the same rule as n^1 and n^0 respectively + */ + if (k == 0) { return 1; + } else if (k == 1) { + return n; + } else if (k > (n / 2)) { + k = n - k; + } + /*! + * (n - k) + i returns 1 higher each loop imitating a factorial calculation. + * Then imagine i as the size of each set, divide by it to find the amount + * of possible sets in result amount of possibilities + */ size_t result = 1; for (int32_t i = 1; i <= k; ++i) { - result *= n - k + i; + result *= (n - k) + i; result /= i; } return result; } -} // namespace binomial } // namespace math /** @@ -54,17 +81,16 @@ size_t calculate(int32_t n, int32_t k) { * @returns void */ static void tests() { - // tests for calculate function - assert(math::binomial::calculate(1, 1) == 1); - assert(math::binomial::calculate(57, 57) == 1); - assert(math::binomial::calculate(6, 3) == 20); - assert(math::binomial::calculate(10, 5) == 252); - assert(math::binomial::calculate(20, 10) == 184756); - assert(math::binomial::calculate(30, 15) == 155117520); - assert(math::binomial::calculate(40, 20) == 137846528820); - assert(math::binomial::calculate(50, 25) == 126410606437752); - assert(math::binomial::calculate(60, 30) == 118264581564861424); - assert(math::binomial::calculate(62, 31) == 465428353255261088); + assert(math::calculate(1, 1) == 1); + assert(math::calculate(57, 57) == 1); + assert(math::calculate(6, 3) == 20); + assert(math::calculate(10, 5) == 252); + assert(math::calculate(20, 10) == 184756); + assert(math::calculate(30, 15) == 155117520); + assert(math::calculate(40, 20) == 137846528820); + assert(math::calculate(50, 25) == 126410606437752); + assert(math::calculate(60, 30) == 118264581564861424); + assert(math::calculate(62, 31) == 465428353255261088); std::cout << "[+] Binomial coefficients calculate test completed" << std::endl; @@ -72,21 +98,9 @@ static void tests() { /** * @brief Main function - * @param argc commandline argument count - * @param argv commandline array of arguments * @returns 0 on exit */ -int main(int argc, const char* argv[]) { +int main() { tests(); // run self-test implementations - - if (argc < 3) { - std::cout << "Usage ./binomial_calculate {n} {k}" << std::endl; - return 0; - } - - int32_t n = atoi(argv[1]); - int32_t k = atoi(argv[2]); - - std::cout << math::binomial::calculate(n, k) << std::endl; return 0; } From ce9ca3ffc7bb9c089e096a918c0d4753f20bdb73 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 23 May 2023 17:46:44 +0100 Subject: [PATCH 02/11] Update math/binomial_calculate.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/binomial_calculate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index a1697c71464..8bf4c052ae9 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -7,8 +7,7 @@ * quoted from: [Weisstein, Eric W. "Binomial Coefficient." From MathWorld--A * Wolfram Web * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The - * binomial coefficient [; meaning n above k in brackets, how binomial - * coefficients are notated] (n; k) is the number of ways of picking k unordered + * binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered * outcomes from n possibilities, also known as a combination or combinatorial * number. The symbols [ _ representing subscript ] _nC_k and (n; k) are used to * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) From a344a70816ebea85b8b694ef105ea05bcfcfe9b7 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 23 May 2023 17:47:07 +0100 Subject: [PATCH 03/11] Update math/binomial_calculate.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/binomial_calculate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index 8bf4c052ae9..ddd1f121bee 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -8,7 +8,7 @@ * Wolfram Web * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The * binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered - * outcomes from n possibilities, also known as a combination or combinatorial + * outcomes from \f$n\f$ possibilities, also known as a combination or combinatorial * number. The symbols [ _ representing subscript ] _nC_k and (n; k) are used to * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) * therefore gives the number of k-subsets possible out of a set of n distinct From 7bcc88fc734e8811977d5614d780680adf4d14a9 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 23 May 2023 17:47:29 +0100 Subject: [PATCH 04/11] Update math/binomial_calculate.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/binomial_calculate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index ddd1f121bee..683df1c3c91 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -9,7 +9,7 @@ * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The * binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered * outcomes from \f$n\f$ possibilities, also known as a combination or combinatorial - * number. The symbols [ _ representing subscript ] _nC_k and (n; k) are used to + * number. The symbols \f$ _nC_k \f$ and \f$ \binom{n}{k} \f$ are used to * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) * therefore gives the number of k-subsets possible out of a set of n distinct * items. For example, The 2-subsets of {1,2,3,4} are the six pairs {1,2}, From f811f2daa12147a5dd6fed5385354279b5f9108b Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 23 May 2023 17:47:47 +0100 Subject: [PATCH 05/11] Update math/binomial_calculate.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/binomial_calculate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index 683df1c3c91..48062faa0af 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -10,7 +10,7 @@ * binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered * outcomes from \f$n\f$ possibilities, also known as a combination or combinatorial * number. The symbols \f$ _nC_k \f$ and \f$ \binom{n}{k} \f$ are used to - * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) + * denote a binomial coefficient, and are sometimes read as "n choose k." \f$ \binom{n}{k} \f$ * therefore gives the number of k-subsets possible out of a set of n distinct * items. For example, The 2-subsets of {1,2,3,4} are the six pairs {1,2}, * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so (4; 2)=6." [Another good From 07e431bd7dafd6f5f2ab50101e3bbef1d545e4e3 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 23 May 2023 17:48:02 +0100 Subject: [PATCH 06/11] Update math/binomial_calculate.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/binomial_calculate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index 48062faa0af..5f5921f4165 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -16,7 +16,7 @@ * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so (4; 2)=6." [Another good * example/explanation](https://math.stackexchange.com/questions/2172355/probability-notation-two-numbers-stacked-inside-brackets) * - * @note An identity of the binomial coefficient is (n; n-k) This is explained + * @note An identity of the binomial coefficient is \f$ \binom{n}{n-k} \f$ This is explained * partially in the comments of this implementation but in more detail at [Prof. * Tesler: Chapter 3.3, 4.1, 4.3. Binomial Coefficient * Identities](https://mathweb.ucsd.edu/~gptesler/184a/slides/184a_ch4slides_17-handout.pdf From 619ba6641369dd5f80376f540f46b0f34b5985dc Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 30 May 2023 15:06:11 +0100 Subject: [PATCH 07/11] Update binomial_calculate.cpp added latex, changed namespace back to binomial --- math/binomial_calculate.cpp | 56 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index a1697c71464..d617b7961d8 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -7,17 +7,17 @@ * quoted from: [Weisstein, Eric W. "Binomial Coefficient." From MathWorld--A * Wolfram Web * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The - * binomial coefficient [; meaning n above k in brackets, how binomial - * coefficients are notated] (n; k) is the number of ways of picking k unordered - * outcomes from n possibilities, also known as a combination or combinatorial - * number. The symbols [ _ representing subscript ] _nC_k and (n; k) are used to - * denote a binomial coefficient, and are sometimes read as "n choose k." (n; k) + * binomial coefficient binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered + * is the number of ways of picking k unordered + * outcomes from \f$n\f$ possibilities, also known as a combination or combinatorial + * number. The symbols \f$ _nC_k \f$ and \f$ \binom{n}{k} \f$ are used to + * denote a binomial coefficient, and are sometimes read as "n choose k." \f$ \binom{n}{k} \f$ * therefore gives the number of k-subsets possible out of a set of n distinct * items. For example, The 2-subsets of {1,2,3,4} are the six pairs {1,2}, - * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so (4; 2)=6." [Another good + * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so \f$ \binom{4}{2} =6.\f$ " [Another good * example/explanation](https://math.stackexchange.com/questions/2172355/probability-notation-two-numbers-stacked-inside-brackets) * - * @note An identity of the binomial coefficient is (n; n-k) This is explained + * @note An identity of the binomial coefficient is \f$ \binom{n}{n-k} \f$ This is explained * partially in the comments of this implementation but in more detail at [Prof. * Tesler: Chapter 3.3, 4.1, 4.3. Binomial Coefficient * Identities](https://mathweb.ucsd.edu/~gptesler/184a/slides/184a_ch4slides_17-handout.pdf @@ -30,10 +30,12 @@ #include /// for IO operations /** - * @namespace math - * @brief Mathematical algorithms + * @namespace binomial + * @brief Functions for [Binomial + * coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient) + * implementation */ -namespace math { +namespace binomial { /** * @brief Function to calculate binomial coefficients * @param n number of possibilities @@ -44,14 +46,14 @@ namespace math { */ size_t calculate(int32_t n, int32_t k) { /*! - * Why do we do if k > (n/2) then k = n-k? Because (n;k) is the same as - * (n;n-k) or, in this case, (6;4) is the same as (6;2) since both are - * calculated for n!/k!(n-k)! , in this case 6!/4!2! . By replacing k with - * n-k we get 6!/2!4! which is the same sum. the benefit however, is our + * Why do we do if k > (n/2) then k = n-k? Because \f$ \binom{n}{k} \f$ is the same as + * \f$ \binom{n}{n-k} \f$ or, in this case, \f$ \binom{6}{4} \f$ is the same as \f$ \binom{6}{2} \f$ since both are + * calculated for \f$ n!/k!(n-k)! \f$, in this case \f$ 6!/4!2! \f$. By replacing \f$ k \f$ with + * \f$ n-k \f$ we get \f$ 6!/2!4! \f$ which is the same sum. the benefit however, is our * loop further on in this implementation now requires less iterations to * find the same answer. * - * k == 1 and k == 0 follow the same rule as n^1 and n^0 respectively + * k == 1 and k == 0 follow the same rule as \f$ n^1 \f$and \f$ n^0 \f$ respectively */ if (k == 0) { return 1; @@ -74,25 +76,25 @@ size_t calculate(int32_t n, int32_t k) { return result; } -} // namespace math +} // namespace binomial /** * @brief Test implementations * @returns void */ static void tests() { - assert(math::calculate(1, 1) == 1); - assert(math::calculate(57, 57) == 1); - assert(math::calculate(6, 3) == 20); - assert(math::calculate(10, 5) == 252); - assert(math::calculate(20, 10) == 184756); - assert(math::calculate(30, 15) == 155117520); - assert(math::calculate(40, 20) == 137846528820); - assert(math::calculate(50, 25) == 126410606437752); - assert(math::calculate(60, 30) == 118264581564861424); - assert(math::calculate(62, 31) == 465428353255261088); + assert(binomial::calculate(1, 1) == 1); + assert(binomial::calculate(57, 57) == 1); + assert(binomial::calculate(6, 3) == 20); + assert(binomial::calculate(10, 5) == 252); + assert(binomial::calculate(20, 10) == 184756); + assert(binomial::calculate(30, 15) == 155117520); + assert(binomial::calculate(40, 20) == 137846528820); + assert(binomial::calculate(50, 25) == 126410606437752); + assert(binomial::calculate(60, 30) == 118264581564861424); + assert(binomial::calculate(62, 31) == 465428353255261088); - std::cout << "[+] Binomial coefficients calculate test completed" + std::cout << "Binomial coefficients tests successfully passed" << std::endl; } From 9ca7bfb851b6011504dee63f9f15f7686934e969 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Tue, 30 May 2023 15:12:22 +0100 Subject: [PATCH 08/11] Update binomial_calculate.cpp --- math/binomial_calculate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index d617b7961d8..6116ec10b1e 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -7,8 +7,7 @@ * quoted from: [Weisstein, Eric W. "Binomial Coefficient." From MathWorld--A * Wolfram Web * Resource.](https://mathworld.wolfram.com/BinomialCoefficient.html) "The - * binomial coefficient binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered - * is the number of ways of picking k unordered + * binomial coefficient \f$ \binom{n}{k} \f$ is the number of ways of picking \f$k\f$ unordered * outcomes from \f$n\f$ possibilities, also known as a combination or combinatorial * number. The symbols \f$ _nC_k \f$ and \f$ \binom{n}{k} \f$ are used to * denote a binomial coefficient, and are sometimes read as "n choose k." \f$ \binom{n}{k} \f$ From 619ec38e1dd8b8a39fbca06900c5d15e8e7f8196 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Sat, 3 Jun 2023 15:06:53 +0100 Subject: [PATCH 09/11] re-added math namespace --- math/binomial_calculate.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index 6116ec10b1e..4e0aacddb8d 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -34,7 +34,7 @@ * coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient) * implementation */ -namespace binomial { +namespace math { namespace binomial { /** * @brief Function to calculate binomial coefficients * @param n number of possibilities @@ -76,22 +76,23 @@ size_t calculate(int32_t n, int32_t k) { return result; } } // namespace binomial +} // namespace math /** * @brief Test implementations * @returns void */ static void tests() { - assert(binomial::calculate(1, 1) == 1); - assert(binomial::calculate(57, 57) == 1); - assert(binomial::calculate(6, 3) == 20); - assert(binomial::calculate(10, 5) == 252); - assert(binomial::calculate(20, 10) == 184756); - assert(binomial::calculate(30, 15) == 155117520); - assert(binomial::calculate(40, 20) == 137846528820); - assert(binomial::calculate(50, 25) == 126410606437752); - assert(binomial::calculate(60, 30) == 118264581564861424); - assert(binomial::calculate(62, 31) == 465428353255261088); + assert(math::binomial::calculate(1, 1) == 1); + assert(math::binomial::calculate(57, 57) == 1); + assert(math::binomial::calculate(6, 3) == 20); + assert(math::binomial::calculate(10, 5) == 252); + assert(math::binomial::calculate(20, 10) == 184756); + assert(math::binomial::calculate(30, 15) == 155117520); + assert(math::binomial::calculate(40, 20) == 137846528820); + assert(math::binomial::calculate(50, 25) == 126410606437752); + assert(math::binomial::calculate(60, 30) == 118264581564861424); + assert(math::binomial::calculate(62, 31) == 465428353255261088); std::cout << "Binomial coefficients tests successfully passed" << std::endl; From ad8c7ec5885e8e98009879178dc72f47da3bd48a Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Thu, 8 Jun 2023 15:48:43 +0100 Subject: [PATCH 10/11] fixed math namespace doc I thought to do this before but forgot to actually do it, whoops! --- math/binomial_calculate.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index 4e0aacddb8d..d281b80b9e6 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -29,6 +29,9 @@ #include /// for IO operations /** + * @namespace math + * @brief Mathematical algorithms + * * @namespace binomial * @brief Functions for [Binomial * coefficients](https://en.wikipedia.org/wiki/Binomial_coefficient) From f8955b8d75708c982bc7f5a0e5e99fcbf3799366 Mon Sep 17 00:00:00 2001 From: ewd00010 <78011234+ewd00010@users.noreply.github.com> Date: Sun, 2 Jul 2023 13:54:19 +0100 Subject: [PATCH 11/11] Update math/binomial_calculate.cpp Co-authored-by: David Leal --- math/binomial_calculate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/math/binomial_calculate.cpp b/math/binomial_calculate.cpp index d281b80b9e6..ed01eb0c86b 100644 --- a/math/binomial_calculate.cpp +++ b/math/binomial_calculate.cpp @@ -13,8 +13,8 @@ * denote a binomial coefficient, and are sometimes read as "n choose k." \f$ \binom{n}{k} \f$ * therefore gives the number of k-subsets possible out of a set of n distinct * items. For example, The 2-subsets of {1,2,3,4} are the six pairs {1,2}, - * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so \f$ \binom{4}{2} =6.\f$ " [Another good - * example/explanation](https://math.stackexchange.com/questions/2172355/probability-notation-two-numbers-stacked-inside-brackets) + * {1,3}, {1,4}, {2,3}, {2,4}, and {3,4}, so \f$ \binom{4}{2} =6.\f$" + * [Another good example/explanation](https://math.stackexchange.com/questions/2172355/probability-notation-two-numbers-stacked-inside-brackets) * * @note An identity of the binomial coefficient is \f$ \binom{n}{n-k} \f$ This is explained * partially in the comments of this implementation but in more detail at [Prof.