Skip to content

Instantly share code, notes, and snippets.

@G33kDude
Last active October 23, 2016 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save G33kDude/7ab8b3cfbc34ea436eb3d4301a810fc3 to your computer and use it in GitHub Desktop.
Save G33kDude/7ab8b3cfbc34ea436eb3d4301a810fc3 to your computer and use it in GitHub Desktop.
Outputs an ASCII mandelbrot set representation without using floating point numbers.
#!/usr/bin/env python3
p = 999
s = 15
for py in range(21*s//10):
row = ''
for px in range(35*s//5):
x0 = (px-50*s//10)*p//s//2
y0 = (py-10*s//10)*p//s
x=0
y=0
i=0
m=99
while (x*x + y*y < 2*2*p*p and i < m):
t = x*x//p - y*y//p + x0
y = 2*x*y//p + y0
x = t
i += 1
row += '*' if i == m else ' '
print(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment