I am trying calculate the following series in JavaScript:
My code is as follows:
var res = []
for(var i=0; i<1000; i++) {
res.push(i / ((i * Math.sqrt(i + 1)) + ((i + 1) * Math.sqrt(i))))
}
But this makes the series possibly converge towards 0 rather than approach 1. Here's the first 150 steps:
Is there something wrong with my translation from math to JavaScript? Maybe my parentheses?
UPDATE
As per @Barmar 's answer, the correct code shows convergence to 1 only for small values of infinity, diverging after 4 steps: