summaryrefslogtreecommitdiff
path: root/math/primitiveRoot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/primitiveRoot.cpp')
-rw-r--r--math/primitiveRoot.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/math/primitiveRoot.cpp b/math/primitiveRoot.cpp
index 7973c24..464bdb3 100644
--- a/math/primitiveRoot.cpp
+++ b/math/primitiveRoot.cpp
@@ -1,12 +1,12 @@
bool isPrimitive(ll g, ll n, ll phi, map<ll, int> phiFacs) {
if (g == 1) return n == 2;
- for (auto& f : phiFacs)
- if (1 == powMod(g, phi / f.first, n)) return false;
+ for (auto [f, _] : phiFacs)
+ if (powMod(g, phi / f, n) == 1) return false;
return true;
}
bool isPrimitive(ll g, ll n) {
- ll phin = phi(n); //isPrime(n) => phi(n) = n - 1
+ ll phin = phi(n); //isPrime(n) => phi(n) = n - 1
map<ll, int> phiFacs;
factor(phin, phiFacs);
return isPrimitive(g, n, phin, phiFacs);