>>12233688It's java.
I have a main class that calls my method/fuction sqrt2
I declare some variables to hold some primative data types (floating points)
then I just set up an algorithm.
I made another more general one for wholes numbers by parameterizing my method with N and replacing my for loop's test for temp1 * temp1 / N
In this algorithm I can store three important values.
first imagine a square with area N where N is a whole number.
I know that x*x = N so x must be < N
and it's obviously greater than 1.
so I set my bounds for 1 and N.
imagine a number line from 1 to N.
you can do various tests such as dividing by two and testing that as your x.
if x^2 > N you know it's not between the average of "N and 1" and N
But if x^2 < N then it's between 1 and the average of 1 and N.
and you continue this method of elimination by taking mid points (which I'm calling averages) and closing your bounds.
You'll use your average as the new test each time.
so it'll temporarily equal x while you test it.
I bet there's a better elimination method.
btu I don't give a fuck.
also I used the other two variables to update my bounds.