Shor's Algorithm

You now have all the pieces for Shor's algorithm. You have code that generates phase estimation for an arbitrary unitary and you have a unitary ($xy \textrm{ mod } N)$ whose eigenvalues give you the period you are looking for.

You just need to put them both together.


A couple comments:

Grading
Show that your quantum computer factors!

Improving Shor's algorithm

There's one more major thing we need to worry about. We wrote this classical simulator but didn't yet think too hard about how fast the algorithm is. Have your code generate circuit descriptions for large values of $N$ (don't try to run them through your simulator). Graph how quickly these grow with $N.$ Is this good enough? If not, how do we fix it?

Grading
Show that your simulator runs faster with the sped-up version.

Congratulations: You now have a simulator that simulates Shor's algorithm.