My function looks like this:
function fn(startValue, iterations){
var result = startValue;
while(iterations--)
{ // Loop the # of iterations
result += 1 / (1 + result);
}
return result;
}
If startValue = 0 and iterations = 3 then the resulting math would be...
startValue = 1 / (1 + startValue);
startValue = 1 / (1 + startValue);
startValue = 1 / (1 + startValue);
And we end up with startValue equaling 1.9
How can I get that same result without looping?
Look at the result. The numerator and denominator are Fibonacci numbers just starting at different places.