Mandelbrot set

You are encouraged to solve this task according to the task description, using any language you may know.


Task

Generate and draw the Mandelbrot set.



Note that there are many algorithms to draw Mandelbrot set and there are many functions which generate it .




 
PROGRAM MANDELBROT
 
!$KEY
!$INCLUDE="PC.LIB"
 
BEGIN
 
SCREEN(7)
GR_WINDOW(-2,1.5,2,-1.5)
FOR X0=-2 TO 2 STEP 0.01 DO
    FOR Y0=-1.5 TO 1.5 STEP 0.01 DO
        X=0
        Y=0
 
        ITERATION=0
        MAX_ITERATION=223
 
        WHILE (X*X+Y*Y<=(2*2) AND ITERATION<MAX_ITERATION) DO
            X_TEMP=X*X-Y*Y+X0
            Y=2*X*Y+Y0
 
            X=X_TEMP
 
            ITERATION=ITERATION+1
        END WHILE
 
        IF ITERATION<>MAX_ITERATION THEN
            C=ITERATION
          ELSE
            C=0
        END IF
 
        PSET(X0,Y0,C)
    END FOR
END FOR
END PROGRAM
 