

def        snake_case__		(    lowerCamelCase_		):
							if upper_limit < 0:
														raise ValueError('''Limit for the Catalan sequence must be ≥ 0'''		)

							A      :					int      		=					[0] * (upper_limit + 1)

							# Base case: C(0) = C(1) = 1
							A      :					Tuple      		=					1
							if upper_limit > 0:
														A      :					int      		=					1

							# Recurrence relation: C(i) = sum(C(j).C(i-j-1)), from j = 0 to i
							for i in range(2     ,				upper_limit + 1		):
														for j in range(lowerCamelCase_		):
																					catalan_list[i] += catalan_list[j] * catalan_list[i - j - 1]

							return catalan_list


if __name__ == "__main__":
		print("\n********* Catalan Numbers Using Dynamic Programming ************\n")
		print("\n*** Enter -1 at any time to quit ***")
		print("\nEnter the upper limit (≥ 0) for the Catalan number sequence: ", end="")
		try:
				while True:
						lowercase			:				Union[str, Any]   =     int(input().strip())
						if N < 0:
								print("\n********* Goodbye!! ************")
								break
						else:
								print(F"The Catalan numbers from 0 through {N} are:")
								print(catalan_numbers(N))
								print("Try another upper limit for the sequence: ", end="")
		except (NameError, ValueError):
				print("\n********* Invalid input, goodbye! ************\n")

		import doctest

		doctest.testmod()









from sympy import diff, lambdify, symbols
from sympy.functions import *  # noqa: F403






def        snake_case__		(    lowerCamelCase_     ,				lowerCamelCase_     ,				lowerCamelCase_ = "x"     ,				lowerCamelCase_ = 10**-10     ,				lowerCamelCase_ = 1     ,				):
							A      :					int      		=					symbols(lowerCamelCase_		)
							A      :					List[str]      		=					lambdify(lowerCamelCase_     ,				lowerCamelCase_		)
							A      :					Tuple      		=					lambdify(lowerCamelCase_     ,				diff(lowerCamelCase_     ,				lowerCamelCase_		)		)

							A      :					Optional[int]      		=					starting_point

							while True:
														if diff_function(lowerCamelCase_		) != 0:
																					A      :					Union[str, Any]      		=					prev_guess - multiplicity * func(lowerCamelCase_		) / diff_function(
																					    lowerCamelCase_		)
														else:
																					raise ZeroDivisionError('''Could not find root'''		) from None

														# Precision is checked by comparing the difference of consecutive guesses
														if abs(next_guess - prev_guess		) < precision:
																					return next_guess

														A      :					Tuple      		=					next_guess


# Let's Execute
if __name__ == "__main__":
		# Find root of trigonometric function
		# Find value of pi
		print(F"The root of sin(x) = 0 is {newton_raphson('sin(x)', 2)}")

		# Find root of polynomial
		# Find fourth Root of 5
		print(F"The root of x**4 - 5 = 0 is {newton_raphson('x**4 -5', 0.4 +5J)}")

		# Find value of e
		print(
		    "The root of log(y) - 1 = 0 is ",
		    F"{newton_raphson('log(y) - 1', 2, variable='y')}",
		)

		# Exponential Roots
		print(
		    "The root of exp(x) - 1 = 0 is",
		    F"{newton_raphson('exp(x) - 1', 10, precision=0.0_05)}",
		)

		# Find root of cos(x)
		print(F"The root of cos(x) = 0 is {newton_raphson('cos(x)', 0)}")






