I have an algorithm for primitive roots for input number $n$ that I believe is $O(n)$ currently. I also have separate algorithms for $\varphi(n)$ and $factorise(n)$ which I believe are both $O(\sqrt{n})$ whose results are used in my primitive root algorithm.
The primitive root alg is based on this Wikipedia entry:
First, compute $\varphi(n)$. Then determine different prime factors of $\varphi(n)$, say $p_1, \cdots, p_k$. Now, for every element m of $\mathbb{Z}_n^*$, compute $$m^{\varphi(n)/p_i}\pmod{n}$$ for $i=1, \cdots,k$, using a fast algorithm for modular exponentiation such as exponentiation by squaring.
A number $m$ for which these $k$ results are all different from $1$ is a primitive root.
Question:
I'm looking for examples of efficient algorithms for Primitive roots where time-complexity is $\leq O(\sqrt{n})$.
I have found lots of examples of algorithms that find primitive roots online, however they do not have the time-complexity noted.