Skip to content

Instantly share code, notes, and snippets.

@evidanary
Created June 16, 2017 21:54
Show Gist options
  • Select an option

  • Save evidanary/7da630e732c840d38387067c8ab3bd2f to your computer and use it in GitHub Desktop.

Select an option

Save evidanary/7da630e732c840d38387067c8ab3bd2f to your computer and use it in GitHub Desktop.

Revisions

  1. evidanary created this gist Jun 16, 2017.
    7 changes: 7 additions & 0 deletions sq_root.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # 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