Skip to content

Instantly share code, notes, and snippets.

@jpoz
Created October 15, 2009 21:17
Show Gist options
  • Select an option

  • Save jpoz/211290 to your computer and use it in GitHub Desktop.

Select an option

Save jpoz/211290 to your computer and use it in GitHub Desktop.
def sqrt(number)
num = min = 0.0
max = number
while true do
num = (min + ((max-min) / 2.0))
t = (num * num)
break if t == number
t > number ? max = num : min = num
end
num
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment