



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):
			lowercase__					  =				0
			lowercase__					  =				len(lowerCamelCase_  ) - 1

			while left <= right:
						# avoid divided by 0 during interpolation
						if sorted_collection[left] == sorted_collection[right]:
									if sorted_collection[left] == item:
												return left
									else:
												return None

						lowercase__					  =				left + ((item - sorted_collection[left]) * (right - left)) // (
						    sorted_collection[right] - sorted_collection[left]
						)

						# out of range check
						if point < 0 or point >= len(lowerCamelCase_  ):
									return None

						lowercase__					  =				sorted_collection[point]
						if current_item == item:
									return point
						else:
									if point < left:
												lowercase__					  =				left
												lowercase__					  =				point
									elif point > right:
												lowercase__					  =				right
												lowercase__					  =				point
									else:
												if item < current_item:
															lowercase__					  =				point - 1
												else:
															lowercase__					  =				point + 1
			return None



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):

			if sorted_collection[left] == sorted_collection[right]:
						if sorted_collection[left] == item:
									return left
						else:
									return None

			lowercase__					  =				left + ((item - sorted_collection[left]) * (right - left)) // (
			    sorted_collection[right] - sorted_collection[left]
			)

			# out of range check
			if point < 0 or point >= len(lowerCamelCase_  ):
						return None

			if sorted_collection[point] == item:
						return point
			elif point < left:
						return interpolation_search_by_recursion(lowerCamelCase_						,  lowerCamelCase_						,  lowerCamelCase_						,  lowerCamelCase_  )
			elif point > right:
						return interpolation_search_by_recursion(lowerCamelCase_						,  lowerCamelCase_						,  lowerCamelCase_						,  lowerCamelCase_  )
			else:
						if sorted_collection[point] > item:
									return interpolation_search_by_recursion(
									    lowerCamelCase_						,  lowerCamelCase_						,  lowerCamelCase_						,  point - 1  )
						else:
									return interpolation_search_by_recursion(
									    lowerCamelCase_						,  lowerCamelCase_						,  point + 1						,  lowerCamelCase_  )



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_  ):

			if collection != sorted(lowerCamelCase_  ):
						raise ValueError("Collection must be ascending sorted"  )
			return True


if __name__ == "__main__":
							import sys
							lowercase_								=     0
							if debug == 1:
														lowercase_								=     [10, 30, 40, 45, 50, 66, 77, 93]
														try:
																					__assert_sorted(collection)
														except ValueError:
																					sys.exit("""Sequence must be ascending sorted to apply interpolation search""")
														lowercase_								=     67

							lowercase_								=     interpolation_search(collection, target)
							if result is not None:
														print(F'{target} found at positions: {result}')
							else:
														print("""Not found""")









def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_  ):
			if upper_limit < 0:
						raise ValueError("Limit for the Catalan sequence must be ≥ 0"  )

			lowercase__					  =				[0] * (upper_limit + 1)

			# Base case: C(0) = C(1) = 1
			lowercase__					  =				1
			if upper_limit > 0:
						lowercase__					  =				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(SCREAMING_SNAKE_CASE_  ):
									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_								=     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()




