Skip to content

Instantly share code, notes, and snippets.

View derekbassett's full-sized avatar

Derek Bassett derekbassett

View GitHub Profile
@derekbassett
derekbassett / gist:c4cb100b8ec8555682d67b2338f2c669
Created February 25, 2017 16:57 — forked from abesto/gist:3476594
Go: Newton's method for square root
/*
A Tour of Go: page 44
http://tour.golang.org/#44
Exercise: Loops and Functions
As a simple way to play with functions and loops, implement the square root function using Newton's method.
In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: z - (z*z - x) / (2 * z)