MC-XOBAHCK,
function fun(start, end, step) {
step = step || (start > end ? -1 : 1);
var n = (end - start) / step | 0;
return (start + n * step / 2) * ++n
}
alert(fun(10, 1, -1));
alert(fun(1, 10, 1));
alert(fun(10, 1));
alert(fun(1, 10));
https://javascript.ru/forum/misc/731...-shagom-2.html