It is worth noting that there is a polynomial time algorithm to determine whether or not a number is prime, but for composite numbers, this algorithm does not provide a factorization. Factoring is a particularly important example because various encryption algorithms such as RSA (used in the PGP software) depend for their security on the difficulty of factoring numbers with several hundred digits.
The action of this transformation on a vector of dimension q looks as though it would take the q2 operations of matrix multiplication, but there is enough structure that the classical fast Fourier transform algorithm can be done in
operations.
The corresponding quantum Fourier transform UQFT with base 2n is defined by