MCPcopy Create free account
hub / github.com/atcoder/ac-library / is_primitive_root

Function is_primitive_root

test/unittest/math_test.cpp:245–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245bool is_primitive_root(int m, int g) {
246 assert(1 <= g && g < m);
247 auto prs = factors(m - 1);
248 for (int x : factors(m - 1)) {
249 if (internal::pow_mod_constexpr(g, (m - 1) / x, m) == 1) return false;
250 }
251 return true;
252}
253
254bool is_primitive_root_naive(int m, int g) {
255 assert(1 <= g && g < m);

Callers 2

TESTFunction · 0.70
TESTFunction · 0.50

Calls 2

pow_mod_constexprFunction · 0.85
factorsFunction · 0.70

Tested by

no test coverage detected