%matplotlib inline

from qiskit import *
from qiskit.visualization import *
from qiskit.tools.monitor import *
from qiskit.aqua import *
from qiskit.aqua.algorithms import *

shor = Shor(N=15, a = 2)
backend = Aer.get_backend('qasm_simulator')
quantum_instance = QuantumInstance(backend)
result = shor.run(quantum_instance)
print(result)

from math import gcd

N=15
print("N=",N)
for a in range(2,N):
    print()
    print("***** a=",a)
    print()
    f = gcd(N,a)
    if f==1:
        shor = Shor(N,a)
        result = shor.run(quantum_instance)
        print(result["factors"])
    else:
        print("A factor of",N,"is",f)
        