
"""simple docstring"""


from math import pow






def    _snake_case					(		snake_case__ :  int						,   snake_case__ :  int						,   snake_case__ :  int						,   snake_case__ :  int						,   snake_case__ :  int						,   ):
	if current_sum == needed_sum:
		# If the sum of the powers is equal to needed_sum, then we have a solution.
		solutions_count += 1
		return current_sum, solutions_count

	A     = int(pow(snake_case__						,   snake_case__  )  )
	if current_sum + i_to_n <= needed_sum:
		# If the sum of the powers is less than needed_sum, then continue adding powers.
		current_sum += i_to_n
		A ,   A     = backtrack(
		    snake_case__						,   snake_case__						,   current_number + 1						,   snake_case__						,   snake_case__  )
		current_sum -= i_to_n
	if i_to_n < needed_sum:
		# If the power of i is less than needed_sum, then try with the next power.
		A ,   A     = backtrack(
		    snake_case__						,   snake_case__						,   current_number + 1						,   snake_case__						,   snake_case__  )
	return current_sum, solutions_count






def    _snake_case					(		snake_case__ :  int						,   snake_case__ :  int  ):
	if not (1 <= needed_sum <= 1000 and 2 <= power <= 10):
		raise ValueError(
		    'Invalid input\n'
		    'needed_sum must be between 1 and 1000, power between 2 and 10.'  )

	return backtrack(snake_case__						,   snake_case__						,   1						,   0						,   0  )[1]  # Return the solutions_count


if __name__ == "__main__":
		import doctest

		doctest.testmod()

"""simple docstring"""




from collections.abc import Callable




def 			_lowerCAmelCase		(		_UpperCamelCase			,					_UpperCamelCase			,					_UpperCamelCase    ):






  """simple docstring"""



  _lowercase:      float   			=  a
  _lowercase:      float   			=  b
  if function(_UpperCamelCase    ) == 0:  # one of the a or b is a root for the function
    return a
  elif function(_UpperCamelCase    ) == 0:
    return b
  elif (
      function(_UpperCamelCase    ) * function(_UpperCamelCase    ) > 0
  ):  # if none of these are root and they are both positive or negative,
    # then this algorithm can't find the root
    raise ValueError('''could not find root in given interval.'''    )
  else:
    _lowercase:      float   			=  start + (end - start) / 2.0
    while abs(start - mid    ) > 10**-7:  # until precisely equals to 10^-7
      if function(_UpperCamelCase    ) == 0:
        return mid
      elif function(_UpperCamelCase    ) * function(_UpperCamelCase    ) < 0:
        _lowercase:      Union[str, Any]   			=  mid
      else:
        _lowercase:      Any   			=  mid
      _lowercase:      List[Any]   			=  start + (end - start) / 2.0
    return mid




def 			_lowerCAmelCase		(		_UpperCamelCase    ):






  """simple docstring"""



  return x**3 - 2 * x - 5


if __name__ == "__main__":
  print(bisection(f, 1, 1_0_0_0))

  import doctest

  doctest.testmod()
