Skip to content

Instantly share code, notes, and snippets.

@hitode909
Last active December 28, 2015 21:09
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 hitode909/7562180 to your computer and use it in GitHub Desktop.
Save hitode909/7562180 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func Cbrt(x complex128) func() complex128 {
z := complex128(1)
return func() complex128 {
z=z-(z*z*z-x)/(3*z*z)
return z
}
}
func main() {
cbrt2:=Cbrt(2)
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
fmt.Println(cbrt2())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment