blob: c2a77f67618c9bc9675269b0eeeed430575f92e3 [file] [log] [blame]
function sumOfArithSeries(limit) {
return limit * (limit + 1) / 2;
}
var n = 10000000;
function foo() {
var result = 0;
for (var i = 0; i < n; ++i) {
var leaf = {f:i};
var o = {f:leaf};
var p = {f:leaf};
var q = {f:o, g:p};
result += q.f.f.f;
}
return result;
}
var result = foo();
if (result != sumOfArithSeries(n - 1))
throw "Error: bad result: " + result;