Skip to content

Instantly share code, notes, and snippets.

@JuliusNM
Created September 28, 2016 21:15
Show Gist options
  • Save JuliusNM/ecb0cf8a939c120e2af6b67c80c1e48b to your computer and use it in GitHub Desktop.
Save JuliusNM/ecb0cf8a939c120e2af6b67c80c1e48b to your computer and use it in GitHub Desktop.
def square_root (n,d)
x = (n* 1.0) / 2
y = (x + (n /x)) /2
while (x - y).abs >= d
x = y
y = (x + (n / x)) / 2
end
y
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment