





import colorsys

from PIL import Image  # type: ignore




def 		lowerCAmelCase_    (  __UpperCAmelCase:			float		,   __UpperCAmelCase:			float		,   __UpperCAmelCase:			int      )      ->	float:
    UpperCamelCase__							:				str          =      x
    UpperCamelCase__							:				Optional[Any]          =      y
    for step in range(__UpperCAmelCase      ):  # noqa: B007
        UpperCamelCase__							:				Union[str, Any]          =      a * a - b * b + x
        UpperCamelCase__							:				Optional[int]          =      2 * a * b + y
        UpperCamelCase__							:				Optional[int]          =      a_new

        # divergence happens for all complex number with an absolute value
        # greater than 4
        if a * a + b * b > 4:
            break
    return step / (max_step - 1)




def 		lowerCAmelCase_    (  __UpperCAmelCase:			float      )      ->	tuple:
    if distance == 1:
        return (0, 0, 0)
    else:
        return (255, 255, 255)




def 		lowerCAmelCase_    (  __UpperCAmelCase:			float      )      ->	tuple:
    if distance == 1:
        return (0, 0, 0)
    else:
        return tuple(round(i * 255      ) for i in colorsys.hsv_to_rgb(__UpperCAmelCase		,   1		,   1      )      )




def 		lowerCAmelCase_    (  __UpperCAmelCase:			int = 800		,   __UpperCAmelCase:			int = 600		,   __UpperCAmelCase:			float = -0.6		,   __UpperCAmelCase:			float = 0		,   __UpperCAmelCase:			float = 3.2		,   __UpperCAmelCase:			int = 50		,   __UpperCAmelCase:			bool = True		,   )      ->	Image.Image:
    UpperCamelCase__							:				Optional[int]          =      Image.new('''RGB'''		,   (image_width, image_height)      )
    UpperCamelCase__							:				Optional[int]          =      img.load()

    # loop through the image-coordinates
    for image_x in range(__UpperCAmelCase      ):
        for image_y in range(__UpperCAmelCase      ):
            # determine the figure-coordinates based on the image-coordinates
            UpperCamelCase__							:				Any          =      figure_width / image_width * image_height
            UpperCamelCase__							:				int          =      figure_center_x + (image_x / image_width - 0.5) * figure_width
            UpperCamelCase__							:				List[Any]          =      figure_center_y + (image_y / image_height - 0.5) * figure_height

            UpperCamelCase__							:				Union[str, Any]          =      get_distance(__UpperCAmelCase		,   __UpperCAmelCase		,   __UpperCAmelCase      )

            # color the corresponding pixel based on the selected coloring-function
            if use_distance_color_coding:
                UpperCamelCase__							:				Union[str, Any]          =      get_color_coded_rgb(__UpperCAmelCase      )
            else:
                UpperCamelCase__							:				Dict          =      get_black_and_white_rgb(__UpperCAmelCase      )

    return img


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  # colored version, full figure
  UpperCAmelCase_     							= get_image()

  # uncomment for colored version, different section, zoomed in
  # img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
  # figure_width = 0.8)

  # uncomment for black and white version, full figure
  # img = get_image(use_distance_color_coding = False)

  # uncomment to save the image
  # img.save("mandelbrot.png")

  img.show()








def 		lowerCAmelCase_    (  __UpperCAmelCase:			int = 100_0000      )      ->	int:
    UpperCamelCase__							:				str          =      limit + 1
    UpperCamelCase__							:				List[str]          =      [0] * limit
    for first_term in range(1		,   __UpperCAmelCase      ):
        for n in range(__UpperCAmelCase		,   __UpperCAmelCase		,   __UpperCAmelCase      ):
            UpperCamelCase__							:				str          =      first_term + n / first_term
            if common_difference % 4:  # d must be divisble by 4
                continue
            else:
                common_difference /= 4
                if (
                    first_term > common_difference
                    and first_term < 4 * common_difference
                ):  # since x,y,z are positive integers
                    frequency[n] += 1  # so z>0 and a>d ,also 4d<a

    UpperCamelCase__							:				Any          =      sum(1 for x in frequency[1:limit] if x == 10      )

    return count


if __name__ == "__main__":
  print(F'''{solution() = }''')

