我尝试比较以下之间的分解时间:1)经典算法函数:
def is_prime1(n):
if n<2:
return False
for i in range(2,n):
if n % i ==0:
return False
return True
def output_prime_factors(num):
num=round(num)
p=0
while p < num:
p +=1
if num % p==0 and is_prime1(p)==True:
print (p)
在 Qiskit (IBM) 上的 Shor 算法,但输出是 Unexpected thatquantum is slow 是如何发生的)
N = 15
shor = Shor(N)
backend = BasicAer.get_backend('qasm_simulator')
quantum_instance = QuantumInstance(backend, shots=1024)
result = shor.run(quantum_instance)
print(f"The list of factors of {N} as computed by the Shor's algorithm is
{result['factors'][0]}.")
qiskit 比经典函数慢