function getArithmeticProgressionSum(max) {
const min = 1, step = 1;
if (max < min || max % step > 0) {
throw new Error('Invalid first argument');
}
return (min + max) / 2 * (max / step);
}
alert(getArithmeticProgressionSum(2) === 3);
alert(getArithmeticProgressionSum(8) === 36);