Choose and prepare . The circuit from part (iii) returns
so a quantum measurement in the computational basis of the first register reveals the discrete logarithm exactly. More generally, any that is invertible modulo returns , from which follows by multiplication by the modular inverse of .