


'''simple docstring'''



import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute







def       _UpperCamelCase (						UpperCamelCase__ = 3   ):
			if isinstance(UpperCamelCase__	, UpperCamelCase__   ):
						raise TypeError("""number of qubits must be a integer."""   )
			if number_of_qubits <= 0:
						raise ValueError("""number of qubits must be > 0."""   )
			if math.floor(UpperCamelCase__   ) != number_of_qubits:
						raise ValueError("""number of qubits must be exact integer."""   )
			if number_of_qubits > 1_0:
						raise ValueError("""number of qubits too large to simulate(>10)."""   )

			UpperCAmelCase__					:   Any       				=       QuantumRegister(UpperCamelCase__	, """qr"""   )
			UpperCAmelCase__					:   Any       				=       ClassicalRegister(UpperCamelCase__	, """cr"""   )

			UpperCAmelCase__					:   List[Any]       				=       QuantumCircuit(UpperCamelCase__	, UpperCamelCase__   )

			UpperCAmelCase__					:   List[Any]       				=       number_of_qubits

			for i in range(UpperCamelCase__   ):
						quantum_circuit.h(number_of_qubits - i - 1   )
						counter -= 1
						for j in range(UpperCamelCase__   ):
									quantum_circuit.cp(np.pi / 2 ** (counter - j)	, UpperCamelCase__	, UpperCamelCase__   )

			for k in range(number_of_qubits // 2   ):
						quantum_circuit.swap(UpperCamelCase__	, number_of_qubits - k - 1   )

			# measure all the qubits
			quantum_circuit.measure(UpperCamelCase__	, UpperCamelCase__   )
			# simulate with 10000 shots
			UpperCAmelCase__					:   List[str]       				=       Aer.get_backend("""qasm_simulator"""   )
			UpperCAmelCase__					:   Tuple       				=       execute(UpperCamelCase__	, UpperCamelCase__	, shots=1_0_0_0_0   )

			return job.result().get_counts(UpperCamelCase__   )


if __name__ == "__main__":
		print(
		    f"""Total count for quantum fourier transform state is: \
    {quantum_fourier_transform(3)}"""
		)



'''simple docstring'''



def       _UpperCamelCase (						UpperCamelCase__ = 1_0	, UpperCamelCase__ = 2_2   ):
			UpperCAmelCase__					:   List[str]       				=       range(1	, UpperCamelCase__   )
			UpperCAmelCase__					:   int       				=       range(1	, UpperCamelCase__   )
			return sum(
			    1 for power in powers for base in bases if len(str(base**power   )   ) == power   )


if __name__ == "__main__":
		print(f"""{solution(10, 22) = }""")