#!pike int BAILOUT = 16; int MAX_ITERATIONS = 1000; int iterate( float x, float y) { float cr = y-0.5; float ci = x; float zi = 0.0; float zr = 0.0; int i = 0; while( 1 ){ i = i+1; float temp = zr * zi; float zr2 = zr*zr; float zi2 = zi*zi; zr = zr2-zi2+cr; zi = temp+temp+ci; if (zi2+zr2 > BAILOUT) { return i; } if (i > MAX_ITERATIONS) { return 0; } } } void mandelbrot(){ //float t = os.time() float y; float x; for( y = -39.0 ; y < 38.0 ; y += 1.0 ) { for( x = -39.0 ; x < 38.0 ; x += 1.0 ) { if (iterate(x/40.0, y/40) == 0) { write("*"); } else { write(" "); } } write("\n"); } //io.write(string.format("Time Elapsed %d\n", os.time() - t)); } void main(){ mandelbrot(); }