Solution (source code)

= Solution

With the positive-exponent convention,
$$
\boxed{
\operatorname{QFT}_M|x\rangle
=\frac1{\sqrt M}\sum_{u=0}^{M-1}e^{2\pi i xu/M}|u\rangle.}
$$
The opposite sign convention is equivalent after conjugating all Fourier phases.