%This program draws the mandelbrot set.
%A complex number c is in the Mandelbrot set if Q_c^n(0) does not approach
%infinity.  Here Q_c(x) = x^2 + c.
%The user inputs the number n of iterations to test
%and the number p of points to plot.

clear all
close all

p=input('Enter the number of points to plot: ');
n=input('Enter the number of iterations n: ');

figure
hold on

for k=1:p
c=rand;
c=c+i*rand;
c=c.*4;
c=c-(2+2i);

x=0;
y=x;


for j=1:n
y=y.^2 + c;
end

if abs(y) <= 2
   plot(c,'k.')
end
end

