Skip to content

Instantly share code, notes, and snippets.

@fgalassi
Created June 8, 2015 10:39
Show Gist options
  • Save fgalassi/a4e021a26e2066211cf3 to your computer and use it in GitHub Desktop.
Save fgalassi/a4e021a26e2066211cf3 to your computer and use it in GitHub Desktop.
def square_root(x, guess)
puts "guessing: #{guess}"
if guess * guess == x
guess
else
new_guess = (guess + x / guess) / 2
square_root(x, new_guess)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment