



'''simple docstring'''

from collections.abc import Callable

_A					:     Optional[int]      =Callable[[float], float]  # type alias for a real -> real function







def     __UpperCamelCase					(				_lowercase,					_lowercase,					_lowercase,					)			->      float:
	_lowercase       :							str  	=		float(_lowercase       )
	while True:
		try:
			_lowercase       :							List[str]  	=		prev_guess - function(_lowercase       ) / derivative(_lowercase       )
		except ZeroDivisionError:
			raise ZeroDivisionError('Could not find root'       ) from None
		if abs(prev_guess - next_guess       ) < 10**-5:
			return next_guess
		_lowercase       :							Tuple  	=		next_guess







def     __UpperCamelCase					(				_lowercase       )			->      float:
	return (x**3) - (2 * x) - 5







def     __UpperCamelCase					(				_lowercase       )			->      float:
	return 3 * (x**2) - 2


if __name__ == "__main__":
		print(newton(f, fa, 3))





'''simple docstring'''

from __future__ import annotations

_A					:     Union[str, Any]      ='''Alexander Joslin'''







def     __UpperCamelCase					(				_lowercase       )			->      int:

	if number <= 0:
		_lowercase       :							Optional[Any]  	=		f'''n must be greater than 0. Got n = {number}'''
		raise ValueError(_lowercase       )

	_lowercase       :							List[str]  	=		[number + 1] * (number + 1)

	# starting position
	_lowercase       :							str  	=		0
	for i in range(1,					_lowercase       ):
		_lowercase       :							Union[str, Any]  	=		min(table[i + 1],					table[i] + 1       )
		# check if out of bounds
		if i * 2 <= number:
			_lowercase       :							Optional[Any]  	=		min(table[i * 2],					table[i] + 1       )
		# check if out of bounds
		if i * 3 <= number:
			_lowercase       :							Any  	=		min(table[i * 3],					table[i] + 1       )
	return table[number]


if __name__ == "__main__":
		import doctest

		doctest.testmod()
