From 2ba05ed8ffa5c8087a7e0a99f6f7a6db1f248e1c Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Thu, 22 Oct 2020 06:37:33 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for f6df24a5 --- math/ncr_modulo_p.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/math/ncr_modulo_p.cpp b/math/ncr_modulo_p.cpp index 5f4f61d46..2e15cc109 100644 --- a/math/ncr_modulo_p.cpp +++ b/math/ncr_modulo_p.cpp @@ -8,20 +8,20 @@ #include #include - /** Class which contains all methods required for calculating nCr mod p * */ class NCRModuloP { -private: + private: std::vector fac; int64_t p; -public: + + public: /** Constructor which precomputes the values of n! % mod from n=0 to size * and stores them in vector 'fac' * @params[in] the numbers 'size', 'mod' - */ - NCRModuloP(int64_t size, int64_t mod){ + */ + NCRModuloP(int64_t size, int64_t mod) { p = mod; fac = std::vector(size); fac[0] = 1; @@ -60,8 +60,7 @@ public: int64_t g = gcdExtended(a, m, &x, &y); if (g != 1) { // modular inverse doesn't exist return -1; - } - else { + } else { int64_t res = (x % m + m) % m; return res; } @@ -80,7 +79,7 @@ public: if (r == 1) { return n % p; } - if (r == 0 || r == n){ + if (r == 0 || r == n) { return 1; } // fac is a global array with fac[r] = (r! % p) @@ -100,12 +99,11 @@ void tests(NCRModuloP ncrObj) { // (52323 C 26161) % (1e9 + 7) = 224944353 assert(ncrObj.ncr(52323, 26161, 1000000007) == 224944353); // 6 C 2 = 30, 30%5 = 0 - assert(ncrObj.ncr(6,2,5) == 0); + assert(ncrObj.ncr(6, 2, 5) == 0); // 7C3 = 35, 35 % 29 = 8 - assert(ncrObj.ncr(7,3,29) == 6); + assert(ncrObj.ncr(7, 3, 29) == 6); } - /** * @brief Main function * @returns 0 on exit