ASCII Art: Mandelbrot Fractal



Mandelbrot Set ASCII
Click to zoom in



At the top of Ken Perlin’s homepage there is a strange C code:

COMPILE THIS:
main(k){float i,j,r,x,y=-16;while(puts(""),y++<15)for(x
=0;x++<84;putchar(" .:-;!/>)|&IH%*#"[k&15]))for(i=k=r=0;
j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111;r=j);}

I couldn't resist to test it. I just modified it a little bit to make it more readable:

int main(int argc, char** argv)
{
  int k = 2;
  float i,j,r,x,y=-16;
  while (puts(""), y++<15)
    for (x=0; x++<84; putchar(" .:-;!/>)|&IH%*#"[k&15]))
      for (i=k=r=0; 
           j=r*r-i*i-2+x/25,i=2*r*i+y/10,j*j+i*i<11&&k++<111; 
           r=j);
  return 0;
}

The result of the execution of this code ? Simply the Mandrelbrot set in ASCII ;)

[via]




Geeks3D.com

↑ Grab this Headline Animator