# Shor's implementation problem on qiskit

1. If q4-7 are all supposed to be eigenstates of the operation, why is it just that q7 is in $$|1\rangle$$? Shouldn't all qubits 4 to 7 be in the $$|1\rangle$$ state to kick back phases from the $$Rz$$ gates applied? 2. I'm trying to see what's inside each of those controlled operations, and as observed below it's a bunch of swap gates. How do swap gates do any meaningful computation? How do they kickback an important phase? I was expecting same quantum gates applied on the eigenstate such that an important phase gets kicked up, so I don't see the point in swap gates. How do swap gates do any meaningful computation? How do they kickback an important phase? I was expecting same quantum gates applied on the eigenstate such that an important phase gets kicked up

What makes you think swap gates can't have phase kickback? The swap operation has both +1 and -1 eigenspaces. For example: First question

There are two implementation of Shor algorithm. The first one is depicted in this picture: In this case, a function $$a^x \mod N$$ is implemented in $$U_f$$ gate and you are trying to find period in such function.

Another implementation (yours one) uses phase estimation for finding the period. See thsis implementation on Wiki for example.

In the first case, all qubits are initialized to $$|0\rangle$$. In second case as you can see in Wiki link, qubits used as input to an "operator which phase is estimated" are initialized at $$|1\rangle$$. It seems that part of $$X$$ gates are included into controlled operators (sorry I have not enought time to reconstruct the opeators).

Second question

As the operators are controlled ones, bottom qubits are entangled with top qubits which allow phase kick-back. As a result, you are able to measure the phase on top qubits.

Concerning swap gate, even such gates are able to perform calculation. You can see here how swap gates implement modular multiplication used in the Shor algorithm.