import qiskit
from qiskit import Aer
from qiskit.aqua.algorithms import Shor

N=15

shor = Shor(N)

backend = Aer.get_backend('qasm_simulator')

result = shor.run(backend)
print("The factors of {} computed by the Shor's algorithm: {}.".format(N, result['factors'][0]))

from qiskit.aqua.algorithms import Grover
from qiskit.aqua.components.oracles import TruthTableOracle, LogicalExpressionOracle

truthTable = '0010100101000001'
oracle = TruthTableOracle(truthTable)

grover = Grover(oracle)
result = grover.run(backend)

from qiskit.visualization import plot_histogram
plot_histogram(result['measurement'])

secondOracle = LogicalExpressionOracle('(a & ~b) & (c ^ d)')
grover = Grover(secondOracle)
result = grover.run(backend)
plot_histogram(result['measurement'])