# Quantum Fourier Transform — 3-qubit QFT
import pennylane as qml
import numpy as np

dev = qml.device("default.qubit", wires=3, shots=1000)

@qml.qnode(dev)
def qft():
    # Prepare input state |101> = 5
    qml.PauliX(wires=0)
    qml.PauliX(wires=2)
    # QFT
    qml.Hadamard(wires=0)
    qml.ControlledPhaseShift(np.pi / 2, wires=[1, 0])
    qml.ControlledPhaseShift(np.pi / 4, wires=[2, 0])
    qml.Hadamard(wires=1)
    qml.ControlledPhaseShift(np.pi / 2, wires=[2, 1])
    qml.Hadamard(wires=2)
    # Swap
    qml.SWAP(wires=[0, 2])
    return qml.counts()

result = qft()
