Created
September 28, 2016 19:15
-
-
Save johnotu/2ac1528bf1e5414aa7cc7085b3e44c97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def square_root (n,d) | |
| g1 = (n* 1.0) / 2 | |
| g2 = (g1 + (n /g1)) /2 | |
| while (g1 - g2).abs >= d | |
| g1 = g2 | |
| g2 = (g1 + (n / g1)) / 2 | |
| end | |
| g2 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment