RosettaCodeData/Task/Mandelbrot-set/Go/mandelbrot-set-1.go
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

24 lines
464 B
Go

package main
import "fmt"
import "math/cmplx"
func mandelbrot(a complex128) (z complex128) {
for i := 0; i < 50; i++ {
z = z*z + a
}
return
}
func main() {
for y := 1.0; y >= -1.0; y -= 0.05 {
for x := -2.0; x <= 0.5; x += 0.0315 {
if cmplx.Abs(mandelbrot(complex(x, y))) < 2 {
fmt.Print("*")
} else {
fmt.Print(" ")
}
}
fmt.Println("")
}
}