Input
Black box for a function
Output
Return
Algorithm
Construct
Consider a state
Since
Do a measurement on the second register of basis
Probability of outcome
By the extended Born Rule
So the measurement gives a uniformly random outcome Post measurement state of the first register is
We apply Quantum Fourier Transform
We can calculate
Thus
Measurement on the first register in
We try
Coprimality Theorem
So repeat this