Sum of first n numbers in JavaScript anWriter