Skip to content

Instantly share code, notes, and snippets.

@evidanary
Created June 16, 2017 21:54
Show Gist options
  • Save evidanary/7da630e732c840d38387067c8ab3bd2f to your computer and use it in GitHub Desktop.
Save evidanary/7da630e732c840d38387067c8ab3bd2f to your computer and use it in GitHub Desktop.
# Square root of a number
# Use newton rhapson's method
def sqrt(x)
r = x
r = (r + x/r) / 2 while r*r > x
r
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment