Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Why are there two `temp`s? Otherwise, it will repeat forever for some numbers.
- * With a single `temp`, sqrt(3) with infinitely iterate between 1.7320508075688772 and 1.7320508075688774
- */
- function sqrt(x){
- let temp,
- temp2,
- i=2*x/(x+1);
- while(temp != i && temp2 != i){
- temp2 = temp;
- temp = i;
- i = (i**2 + x)/(2*i)
- }
- return i
- }
- // It may seem like I stole this from pastebin.com/umyk7xVB but trust me, this is mine.
Add Comment
Please, Sign In to add comment