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/f9cb9087871687b2dbbef5c74932dbf964de02b0e13a1bb6d5e7f1f3e062afa9.png
qc.draw("mpl")
_images/48a8f36078a404524d8373e12ef995c3ac95007d72f24822432e2cdcfe00c139.png