





import math

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




def _a (  SCREAMING_SNAKE_CASE__      :  int = 3       )	->    qiskit.result.counts.Counts:

							'''simple docstring'''






							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 > 10:
														raise ValueError("number of qubits too large to simulate(>10)."       )

							SCREAMING_SNAKE_CASE__       :      List[Any]     =						QuantumRegister(UpperCAmelCase_			,				"qr"       )
							SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						ClassicalRegister(UpperCAmelCase_			,				"cr"       )

							SCREAMING_SNAKE_CASE__       :      Tuple     =						QuantumCircuit(UpperCAmelCase_			,				UpperCAmelCase_       )

							SCREAMING_SNAKE_CASE__       :      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
							SCREAMING_SNAKE_CASE__       :      List[str]     =						Aer.get_backend("qasm_simulator"       )
							SCREAMING_SNAKE_CASE__       :      Optional[int]     =						execute(UpperCAmelCase_			,				UpperCAmelCase_			,				shots=1_00_00       )

							return job.result().get_counts(UpperCAmelCase_       )


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













def _a (  SCREAMING_SNAKE_CASE__      :  int       )	->    str:

							'''simple docstring'''






							if isinstance(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       ):
														raise TypeError("'float' object cannot be interpreted as an integer"       )
							if isinstance(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       ):
														raise TypeError("'str' object cannot be interpreted as an integer"       )

							if num == 0:
														return "0b0"

							SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						False

							if num < 0:
														SCREAMING_SNAKE_CASE__       :      Any     =						True
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						-num

							SCREAMING_SNAKE_CASE__       :      list[int]     =						[]
							while num > 0:
														binary.insert(0			,				num % 2       )
														num >>= 1

							if negative:
														return "-0b" + "".join(str(SCREAMING_SNAKE_CASE__       ) for e in binary       )

							return "0b" + "".join(str(SCREAMING_SNAKE_CASE__       ) for e in binary       )


if __name__ == "__main__":
		import doctest

		doctest.testmod()






