Last active
August 17, 2019 13:59
-
-
Save karlbeecken/5964a5d06fa3288cc10914f128a3c3c9 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
function round(num) { | |
return +(Math.round(num + "e+10") + "e-10"); | |
} | |
function heron_sqrt(num) { | |
let a = num / 3 | |
let b = num / a | |
while (round(Math.pow(a, 2)) !== num) { | |
a = (a + b) / 2 | |
b = num / a | |
} | |
return a | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment