The function returns a string in the format "x.xx". To do this, add a sequence of numbers like this:
1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 + ... n times
each time increasing the divisor by 3.
If the input is 0 or not a number, or a fractional number, it returns "0.00" Here I threw:
function SeriesSum(n){ if (n > 0){ var result = 0; for (var i = 1; i <= (n * 3) + 1; i + 3){ result += (1 / i); } } else { return "0.00"; } return +Math.round(result * 100) / 100; }