




"""simple docstring"""





import qiskit
from qiskit.providers import Backend

def 		lowerCAmelCase							( lowerCamelCase      ,			lowerCamelCase		):
						'''simple docstring'''


						snake_case__       :					Optional[int]										=					bin(lowerCamelCase		)[2:], bin(lowerCamelCase		)[2:]  # Remove leading '0b'

						# Ensure that both strings are of the same length
						if len(lowerCamelCase		) > len(lowerCamelCase		):
												snake_case__       :					List[str]										=					y.zfill(len(lowerCamelCase		)		)
						else:
												snake_case__       :					int										=					x.zfill(len(lowerCamelCase		)		)

						# We need (3 * number of bits in the larger number)+1 qBits
						# The second parameter is the number of classical registers, to measure the result
						snake_case__       :					str										=					qiskit.QuantumCircuit((len(lowerCamelCase		) * 3) + 1      ,			len(lowerCamelCase		) + 1		)

						# We are essentially "not-ing" the bits that are 1
						# Reversed because it's easier to perform ops on more significant bits
						for i in range(len(lowerCamelCase		)		):
												if x[::-1][i] == "1":
																		circuit.x(lowerCamelCase		)
						for j in range(len(lowerCamelCase		)		):
												if y[::-1][j] == "1":
																		circuit.x(len(lowerCamelCase		) + j		)

						return circuit, x, y

def 		lowerCAmelCase							( lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase      ,			):
						'''simple docstring'''


						circuit.ccx(lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase		)
						circuit.cx(lowerCamelCase      ,			lowerCamelCase		)
						circuit.ccx(lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase		)
						circuit.cx(lowerCamelCase      ,			lowerCamelCase		)
						circuit.cx(lowerCamelCase      ,			lowerCamelCase		)

def 		lowerCAmelCase							( lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase = qiskit.Aer.get_backend('''aer_simulator'''		)      ,			):
						'''simple docstring'''


						if vala < 0 or vala < 0:
												raise ValueError('''Both Integers must be positive!'''		)

						# Store the Integers
						snake_case__       :					Any										=					store_two_classics(lowerCamelCase      ,			lowerCamelCase		)
						for i in range(len(lowerCamelCase		)		):
												full_adder(lowerCamelCase      ,			lowerCamelCase      ,			len(lowerCamelCase		) + i      ,			len(lowerCamelCase		) + len(lowerCamelCase		) + i      ,			len(lowerCamelCase		) + len(lowerCamelCase		) + i + 1		)
												circuit.barrier()  # Optional, just for aesthetics

						# Measure the resultant qBits
						for i in range(len(lowerCamelCase		) + 1		):
												circuit.measure([(len(lowerCamelCase		) * 2) + i]      ,			[i]		)

						snake_case__       :					Any										=					qiskit.execute(lowerCamelCase      ,			lowerCamelCase      ,			shots=1		).result()

						# The result is in binary. Convert it back to int
						return int(list(res.get_counts()		)[0]      ,			2		)


if __name__ == "__main__":
							import doctest

							doctest.testmod()








"""simple docstring"""





from __future__ import annotations

def 		lowerCAmelCase							( lowerCamelCase      ,			lowerCamelCase      ,			lowerCamelCase      ,			):
						'''simple docstring'''


						if not all((nth_term, start_term_a, common_ratio_r)		):
												return []
						snake_case__       :					list[float | int]										=					[]
						snake_case__       :					List[str]										=					1
						snake_case__       :					Dict										=					common_ratio_r
						for _ in range(int(lowerCamelCase		)		):
												if not series:
																		series.append(lowerCamelCase		)
												else:
																		power += 1
																		series.append(float(start_term_a * multiple		)		)
																		snake_case__       :					Tuple										=					pow(float(lowerCamelCase		)      ,			lowerCamelCase		)
						return series


if __name__ == "__main__":
							import doctest

							doctest.testmod()

							_lowercase	      =    float(input("""Enter the last number (n term) of the Geometric Series"""))
							_lowercase	      =    float(input("""Enter the starting term (a) of the Geometric Series"""))
							_lowercase	      =    float(
							    input("""Enter the common ratio between two terms (r) of the Geometric Series""")
							)
							print("""Formula of Geometric Series => a + ar + ar^2 ... +ar^n""")
							print(geometric_series(nth_term, start_term_a, common_ratio_r))


