"""simple docstring"""


from __future__ import annotations

from collections.abc import Callable






def     __UpperCAmelCase					(			lowercase   ,lowercase   ,lowercase   ,lowercase = 1_00   ,):







  """simple docstring"""
  _UpperCAmelCase						 =      x_start
  _UpperCAmelCase						 =      fnc(lowerCamelCase__		)
  _UpperCAmelCase						 =      0.0
  for _ in range(lowerCamelCase__		):
    # Approximates small segments of curve as linear and solve
    # for trapezoidal area
    _UpperCAmelCase						 =      (x_end - x_start) / steps + xa
    _UpperCAmelCase						 =      fnc(lowerCamelCase__		)
    area += abs(fxa + fxa		) * (xa - xa) / 2
    # Increment step
    _UpperCAmelCase						 =      xa
    _UpperCAmelCase						 =      fxa
  return area


if __name__ == "__main__":






    def     __UpperCAmelCase					(			lowercase		):







      """simple docstring"""
      return x**3 + x**2

    print("""f(x) = x^3 + x^2""")
    print("""The area between the curve, x = -5, x = 5 and the x axis is:""")
    UpperCAmelCase__  		=     1_0
    while i <= 1_0_0_0_0_0:
        print(F'''with {i} steps: {trapezoidal_area(f, -5, 5, i)}''')
        i *= 1_0

"""simple docstring"""


def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  _UpperCAmelCase						 =      0
  while n > 0:
    res += n % 10
    n //= 10
  return res






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      abs(lowercase		)
  return n if n < 10 else n % 10 + sum_of_digits(n // 10		)






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return sum(int(lowercase		) for c in str(abs(lowercase		)		)		)






def     __UpperCAmelCase					(			):







  """simple docstring"""
  from collections.abc import Callable
  from timeit import timeit

  def benchmark_a_function(lowercase   ,lowercase		) -> None:
    _UpperCAmelCase						 =      f'''{func.__name__}({value})'''
    _UpperCAmelCase						 =      timeit(f'''__main__.{call}'''   ,setup="""import __main__"""		)
    print(f'''{call:56} = {func(lowercase		)} -- {timing:.4f} seconds'''		)

  for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
    for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
      benchmark_a_function(lowercase   ,lowercase		)
    print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()
