0
$\begingroup$

I´m trying to code the shor algorithm for any N and any a but i always find examples of code for the N=15. My first question is how is this funtion( provided by qiskit ) does the exponential modulation since the only thing that is happening is swaps ? then why does the functio recieves the parameter a since it doesnt use it? ANd how can i do a circuit that does this operation for any given a and N?

def a_modN (a,power,n_c):
    U= QuantumCircuit(n_c)
    for iteration in range(power):
        U.swap(2,3)
        U.swap(2,1)
        U.swap(1,0)
        U.x(range(4))
        U.to_gate()
        U.name='%i^%imod15'%(a,power)
        C_u=U.control()
    return C_u
$\endgroup$
2
  • $\begingroup$ Do you have the URL for where the function is from? $\endgroup$ Jul 14, 2023 at 23:06
  • $\begingroup$ youtu.be/EdJ7RoWcU48 i think the code i put here has a small diference but is the one from this video that i dont understand $\endgroup$ Jul 17, 2023 at 9:59

0