MCPcopy Create free account
hub / github.com/cp-algorithms/cp-algorithms / powmod

Function powmod

test/test_discrete_log.cpp:9–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
8
9int powmod(int a, int b, int m) {
10 int res = 1;
11 while (b > 0) {
12 if (b & 1) {
13 res = (res * 1ll * a) % m;
14 }
15 a = (a * 1ll * a) % m;
16 b >>= 1;
17 }
18 return res;
19}
20
21namespace DiscreteLog {
22#include "discrete_log.h"

Callers 1

test_data_okFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected