TITLE: Algorithm for detecting prime powers
QUESTION [6 upvotes]: While reading Peter Shor's paper Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, I came across the following quote:

"This scheme will thus work as long as $n$ is odd and not a prime power; finding factors of prime powers can be done efficiently with classical methods."

I have two questions:
(1) How does one efficiently determine if a given number $N$ is a prime power, and
(2) How does one efficiently determine the factorization of a prime power? 
(Note: I have included these as separate questions since I am aware that many of the standard  algorithms for determining a number is composite will not necessarily produce a proper factor.)

REPLY [12 votes]: See Dan Bernstein's paper, ``Detecting perfect powers in essentially linear time.'' Mathematics of Computation 67 (1998), 1253--1283, available at http://cr.yp.to/papers.html#powers.  Here "linear" means "linear in log n".