Created
October 13, 2016 15:23
-
-
Save ErikBoesen/1530487206a0ffa71edc86ec1e50ecd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "What number do you want to get the square root of? " | |
x = gets.chomp.to_f | |
puts "What's your first guess? " | |
r = gets.chomp.to_f | |
puts "Calculating square root of #{x} with guess #{r}." | |
10.times do |i| | |
r = (r + x/r) / 2 | |
puts "Closer answer: #{r}. Calculating more places..." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment