You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title says. Our primitive root functons outputs -1 for n=2. 1 is actually a primitive root of 2, so the answer should be 1.
Also, we can speed it up because we don't actually need all the divisors of m-1, i.e., the totient function of m (because we're assuming m is prime). We just need the prime factors of m-1.
We can use an optimized $O(\sqrt{m})$ algo to factorize, which would have the same worst-case complexity, but would be much faster than getting all the divisors. The code also won't change very much.
For best speed up, we can use pollard's rho to factorize (but may be unnecesary for most cases).
The text was updated successfully, but these errors were encountered:
As the title says. Our primitive root functons outputs
-1
forn=2
.1
is actually a primitive root of2
, so the answer should be1
.Also, we can speed it up because we don't actually need all the divisors of
m-1
, i.e., the totient function ofm
(because we're assumingm
is prime). We just need the prime factors ofm-1
.We can use an optimized$O(\sqrt{m})$ algo to factorize, which would have the same worst-case complexity, but would be much faster than getting all the divisors. The code also won't change very much.
For best speed up, we can use pollard's rho to factorize (but may be unnecesary for most cases).
The text was updated successfully, but these errors were encountered: