Grover: factorize number

from typing import Tuple
from qlasskit import qlassf, Qint
from qlasskit.algorithms import Grover


@qlassf
def factorize(a: Tuple[Qint[2], Qint[2]]) -> bool:
    return a[0] * a[1] == 9


q_algo = Grover(factorize)
from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_histogram
from qiskit_aer import AerSimulator

qc = q_algo.export("qiskit")
qc.measure_all()
simulator = AerSimulator()
circ = transpile(qc, simulator)
result = simulator.run(circ).result()
counts = result.get_counts(circ)

counts_readable = q_algo.decode_counts(counts, discard_lower=5)
plot_histogram(counts_readable)
_images/9f50a91c8c2b299ea32759349e025d3f82cf115c5fd53686d12279f764c4c401.png
qc.draw("mpl")
_images/c21f6006d9d92f5209910774ce14eb3ed1278e62d3926a4dbbc9241d6c818c0f.png