input: Write a python function to generate the Mandelbrot set and save it as an image file.
  assert mandelbrot(200, 150) == None
  assert mandelbrot(800, 600) == None
  assert os.path.exists('mandelbrot.png') == True
output: def mandelbrot(width, height):
      import numpy as np
      from PIL import Image
  
      def mandelbrot(c, max_iter):
          z = 0
          n = 0
          while abs(z) <= 2 and n < max_iter:
              z = z*z + c
              n += 1
          return n
  
      # Generate the Mandelbrot set
      x_min, x_max = -2.5, 1.5
      y_min, y_max = -1.5, 1.5
      max_iter = 1000
      image = Image.new("RGB", (width, height))
      pixels = image.load()
  
      for x in range(width):
          for y in range(height):
              # Convert pixel coordinate to complex number
              c = complex(x_min + (x / width) * (x_max - x_min),
                          y_min + (y / height) * (y_max - y_min))
              # Compute the color of the pixel
              m = mandelbrot(c, max_iter)
              color = 255 - int(m * 255 / max_iter)
              pixels[x, y] = (color, color, color)
  
      # Save the image
      image.save('mandelbrot.png')