



import math as m

def      A_ (		__a       :			List[Any]	,						__a       :			Optional[int]	,						__a       :			str=0.0_0_1						):

				"""simple docstring"""
				return (f(a + h						) - f(a - h						)) / (2 * h)

def      A_ (		__a       :			Tuple	,						__a       :			Optional[Any]=0	,						__a       :			Tuple=100	,						__a       :			List[Any]=0.0_0_0_1	,						__a       :			Tuple=1e-6	,						__a       :			Optional[Any]=False						):

				"""simple docstring"""
				a__			 =						xa  # set the initial guess
				a__			 =						[a]
				a__			 =						abs(f(A_						)						)
				a__			 =						lambda __a						: calc_derivative(A_	,						A_	,						h=A_						)  # noqa: E731  Derivative of f(x)
				for _ in range(A_						):
								if fa(A_						) == 0:
												raise ValueError("""No converging solution found"""						)
								a__			 =						a - f(A_						) / fa(A_						)  # Calculate the next estimate
								if logsteps:
												steps.append(A_						)
								if error < maxerror:
												break
				else:
								raise ValueError("""Iteration limit reached, no converging solution found"""						)
				if logsteps:
								# If logstep is true, then log intermediate steps
								return a, error, steps
				return a, error


if __name__ == "__main__":
	from matplotlib import pyplot as plt

	UpperCAmelCase												=   lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
	UpperCAmelCase												=   newton_raphson(
	    f, xa=10, maxiter=1_000, step=1E-6, logsteps=True
	)
	plt.plot([abs(f(x)) for x in steps])
	plt.xlabel("""step""")
	plt.ylabel("""error""")
	plt.show()
	print(f"""solution = {{{solution:f}}}, error = {{{error:f}}}""")






def      A_ (		__a       :			int						):

				"""simple docstring"""
				if number != int(__a						):
								raise ValueError("""factorial() only accepts integral values"""						)
				if number < 0:
								raise ValueError("""factorial() not defined for negative values"""						)
				a__			 =						1
				for i in range(1	,						number + 1						):
								value *= i
				return value

def      A_ (		__a       :			int						):

				"""simple docstring"""
				if not isinstance(__a	,						__a						):
								raise ValueError("""factorial() only accepts integral values"""						)
				if n < 0:
								raise ValueError("""factorial() not defined for negative values"""						)
				return 1 if n == 0 or n == 1 else n * factorial(n - 1						)


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	UpperCAmelCase								=   int(input("""Enter a positive integer: """).strip() or 0)
	print(f"""factorial{n} is {factorial(n)}""")

