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