Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

Shor

Shor(N=15, a=2, quantum_instance=None)

GitHub(opens in a new tab)

Shor’s factoring algorithm.

Shor’s Factoring algorithm is one of the most well-known quantum algorithms and finds the prime factors for input integer NN in polynomial time.

The input integer NN to be factored is expected to be odd and greater than 2. Even though this implementation is general, its capability will be limited by the capacity of the simulator/hardware. Another input integer aa can also be supplied, which needs to be a co-prime smaller than NN .

Adapted from https://github.com/ttlion/ShorAlgQiskit(opens in a new tab)

See also https://arxiv.org/abs/quant-ph/0205095(opens in a new tab)

Parameters

  • N (int) – The integer to be factored, has a min. value of 3.

  • a (int) – A random integer that satisfies a < N and gcd(a, N) = 1, has a min. value of 2.

  • quantum_instance (Union[QuantumInstance, BaseBackend, None]) –

    Quantum Instance or Backend

    Raises:

    ValueError: Invalid input


Attributes

backend

qiskit.providers.basebackend.BaseBackend

Returns backend.

Return type

BaseBackend

quantum_instance

Union[None, qiskit.aqua.quantum_instance.QuantumInstance]

Returns quantum instance.

Return type

Optional[QuantumInstance]

random

Return a numpy random.


Methods

construct_circuit

Shor.construct_circuit(measurement=False)

Construct circuit.

Parameters

measurement (bool) – Boolean flag to indicate if measurement should be included in the circuit.

Return type

QuantumCircuit

Returns

Quantum circuit.

run

Shor.run(quantum_instance=None, **kwargs)

Execute the algorithm with selected backend.

Parameters

Returns

results of an algorithm.

Return type

dict

Raises

AquaError – If a quantum instance or backend has not been provided

set_backend

Shor.set_backend(backend, **kwargs)

Sets backend with configuration.

Return type

None

Was this page helpful?
Report a bug or request content on GitHub.