<p>The value of <code>a</code> is part of the phase estimation part of Shor's algorithm, where the operation</p>
<pre><code>|y&gt; -&gt; |ay mod N&gt;
</code></pre>
<p>is applied. So <code>a</code> influences the arithmetic operation and depending on how you implement the modular multiplication influences the final circuit differently.</p>
<p>The Qiskit textbook implementation seems to only support special values of <code>a</code>, but the software package itself has the general code for all values of <code>a</code>: <a href="https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/algorithms/factorizers/shor.py" rel="nofollow noreferrer">https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/algorithms/factorizers/shor.py</a></p>
<p>That code uses the Fourier transform to do the multiplication, so <code>a</code> will influence the phase shifts applied after the Fourier transform. Qiskit's implementation is based on <a href="https://arxiv.org/abs/quant-ph/0205095" rel="nofollow noreferrer">this paper</a> where you can find more information.</p>
One question about circuit realization of Shor's algorithm in quantum computing
<p>I am studying the quantum circuit realization of Shor's algorithm about factoring 15 into product of prime numbers using the python package Qiskit. See this <a href="https://qiskit.org/textbook/ch-algorithms/shor.html" rel="nofollow noreferrer">website</a> for details.</p>
<p>My question is related to the realization of U-gate in this website. In this website, the realization of U-gate is given in the form</p>
<pre><code>def c_amod15(a, power):
    &quot;&quot;&quot;Controlled multiplication by a mod 15&quot;&quot;&quot;
    if a not in [2,7,8,11,13]:
        raise ValueError(&quot;'a' must be 2,7,8,11 or 13&quot;)
    U = QuantumCircuit(4)        
    for iteration in range(power):
        if a in [2,13]:
            U.swap(0,1)
            U.swap(1,2)
            U.swap(2,3)
        if a in [7,8]:
            U.swap(2,3)
            U.swap(1,2)
            U.swap(0,1)
        if a == 11:
            U.swap(1,3)
            U.swap(0,2)
        if a in [7,11,13]:
            for q in range(4):
                U.x(q)
    U = U.to_gate()
    U.name = &quot;%i^%i mod 15&quot; % (a, power)
    c_U = U.control()
    return c_U
</code></pre>
<p>My question is that why this U-gate is engineered in such way by swapping qbits. How exactly the value of 'a' will affect the swapping scheme? What if I want to factor 33? How should I change this swapping scheme to factor 33?</p>