From 5ab8a5088b729a9953b8dff1b2a985dc8fb2098b Mon Sep 17 00:00:00 2001 From: mzuenni Date: Mon, 27 Jun 2022 17:19:28 +0200 Subject: updated tcr --- math/modMulIterativ.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 math/modMulIterativ.cpp (limited to 'math/modMulIterativ.cpp') diff --git a/math/modMulIterativ.cpp b/math/modMulIterativ.cpp new file mode 100644 index 0000000..611f09a --- /dev/null +++ b/math/modMulIterativ.cpp @@ -0,0 +1,9 @@ +ll mulMod(ll a, ll b, ll n) { + ll res = 0; + while (b > 0) { + if (b & 1) res = (a + res) % n; + a = (a * 2) % n; + b /= 2; + } + return res; +} -- cgit v1.2.3