patternModerate
Is there an efficient algorithm to find whether an integer is a prime power?
Viewed 0 times
primeefficientpoweralgorithmfindtherewhetherinteger
Problem
There's a sentence in the current version of the Wikipedia page for Shor's algorithm which states: we can use efficient classical algorithms to check if $N$ is a prime power. No reference is provided to support it.
Is this true? I've tried to look around for such an algorithm but didn't find much.
There is this website providing code to solve this problem, which states that the time complexity is indeed $O(\log N)$, but they also don't provide references, so I'm not sure how reliable it is. The idea of the algorithm seems to be to simply loop over all primes smaller than $\sqrt N$, and each time try to divide until you get to $1$. The reasoning seems sound, but I'm not sure how you verify the complexity of this procedure.
Is this true? I've tried to look around for such an algorithm but didn't find much.
There is this website providing code to solve this problem, which states that the time complexity is indeed $O(\log N)$, but they also don't provide references, so I'm not sure how reliable it is. The idea of the algorithm seems to be to simply loop over all primes smaller than $\sqrt N$, and each time try to divide until you get to $1$. The reasoning seems sound, but I'm not sure how you verify the complexity of this procedure.
Solution
See:
Daniel J. Bernstein. Detecting perfect powers in essentially linear time, Mathematics of Computation 67 (1998), 1253–1283.
Here, "linear" means "linear in $\log N $". Specifically, the complexity is $\left(\log N\right)^{1 + o(1)}$ as $n \rightarrow \infty$.
Daniel J. Bernstein. Detecting perfect powers in essentially linear time, Mathematics of Computation 67 (1998), 1253–1283.
Here, "linear" means "linear in $\log N $". Specifically, the complexity is $\left(\log N\right)^{1 + o(1)}$ as $n \rightarrow \infty$.
Context
StackExchange Computer Science Q#161362, answer score: 17
Revisions (0)
No revisions yet.