A point in the complex plane is said to belong to the Mandelbrot set if the sequence does not diverge when iterated from starting point .
Thus we iterate a fixed number of times and register at what iteration we have .
If that does not happen, then the sequence does not diverge and the point is part of the Mandelbrot set.
Every character space of the Ubuntu console is treated as a point in the complex space and colored according to the loop exiting value.
Save the source code file Mandelbrot.cc
in a folder on your computer. Open a terminal and navigate to you folder with the command cd
, then run the commands
g++ Mandelbrot.cc -std=c++0x -o Mandelbrot
and
./Mandelbrot