z = z^2 + c.
If z remains finite, even after an infinite number of iterations, then the point c is a member of the Mandelbrot set. Since infinity is a very big number, it wouldn't be practical to iterate the equation infinity times so a smaller number like 255 iterations is enough for the job. The points c that are a member of the set get colored black. The points not a member of the set can be colored and given a brightness proportional to the number of iterations taken to escape.
To program the algorithm, you need to think of a square plane of pixels on your computer screen to be the complex plane, where each pixel on that square represents the coordinates of a unique discrete complex number given by the the x and y location of the real and imaginary axis respectively. For each pixel, you need to determine its location on the complex plane and then using that value, seed the above equation with it as c. Then you enter a loop and continuously reiterate that equation until you reach some preset maximum number of iterations like 255. If at any time during the loop, the magnitude of z is greater than 2, you can break out of the loop because you know that seed value doesn't belong to the Mandelbrot Set, and you can assign a color value to that pixel based on how many iterations it took to exit the loop. Otherwise, the seed value is part of the Mandelbrot Set and you can color it black. You do that for every pixel in your square, and the Mandelbrot set appears!
Following are some screen shots of the Mandelbrot Set from a program I recently wrote in Java using the SWT libraries. I added capabilites so I could click on a part of the Mandelbrot Set, triggering the program to zoom deeper to reveal more details. By the way Mandelbrot means "almond bread" in German.