



from __future__ import annotations

from collections.abc import Generator


def       UpperCamelCase(  __UpperCamelCase							:		int			):
		if not isinstance(__UpperCamelCase					,__UpperCamelCase			) or n < 1:
				raise Exception('''Sequence only defined for positive integers'''			)

		yield n
		while n != 1:
				if n % 2 == 0:
						n //= 2
				else:
						lowerCAmelCase_      :					int     =			3 * n + 1
				yield n


def       UpperCamelCase(  ):
		lowerCAmelCase_      :					Dict     =			43
		lowerCAmelCase_      :					int     =			tuple(collatz_sequence(__UpperCamelCase			)			)
		print(__UpperCamelCase			)
		print(f"""Collatz sequence from {n} took {len(__UpperCamelCase			)} steps."""			)


if __name__ == "__main__":
		main()










A__  :  str       = 1000


def       UpperCamelCase(  __UpperCamelCase							:		float			):
		return x * x


def       UpperCamelCase(  __UpperCamelCase							:		Optional[int]					,__UpperCamelCase							:		float					,__UpperCamelCase							:		float					,__UpperCamelCase							:		int = 4			):
		assert callable(
		    __UpperCamelCase			), f"""the function(object) passed should be callable your input : {function}"""
		assert isinstance(__UpperCamelCase					,(float, int)			), f"""a should be float or integer your input : {a}"""
		assert isinstance(function(__UpperCamelCase			)					,(float, int)			), (
		    "the function should return integer or float return type of your function, "
		    f"""{type(__UpperCamelCase			)}"""
		)
		assert isinstance(__UpperCamelCase					,(float, int)			), f"""b should be float or integer your input : {b}"""
		assert (
		    isinstance(__UpperCamelCase					,__UpperCamelCase			) and precision > 0
		), f"""precision should be positive integer your input : {precision}"""

		# just applying the formula of simpson for approximate integration written in
		# mentioned article in first comment of this file and above this function

		lowerCAmelCase_      :					List[str]     =			(b - a) / N_STEPS
		lowerCAmelCase_      :					str     =			function(__UpperCamelCase			) + function(__UpperCamelCase			)

		for i in range(1					,__UpperCamelCase			):
				lowerCAmelCase_      :					Optional[Any]     =			a + h * i
				result += function(__UpperCamelCase			) * (4 if i % 2 else 2)

		result *= h / 3
		return round(__UpperCamelCase					,__UpperCamelCase			)


if __name__ == "__main__":
						import doctest

						doctest.testmod()





