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

Function is_primitive_root_naive

test/unittest/math_test.cpp:254–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254bool is_primitive_root_naive(int m, int g) {
255 assert(1 <= g && g < m);
256 auto prs = factors(m - 1);
257 int x = 1;
258 for (int i = 1; i <= m - 2; i++) {
259 x = (int)((long long)(x)*g % m);
260 // x == n^i
261 if (x == 1) return false;
262 }
263 x = (int)((long long)(x)*g % m);
264 assert(x == 1);
265 return true;
266}

Callers

nothing calls this directly

Calls 1

factorsFunction · 0.70

Tested by

no test coverage detected