Sums all the numbers between 1
and n
.
(n * (n + 1)) / 2
to get the sum of all the numbers between 1 and n
.const sumN = n => (n * (n + 1)) / 2;
sumN(100); // 5050
JavaScript, Math
Calculates the distance between two points in any number of dimensions.
JavaScript, Math
Calculates the sum of the powers of all the numbers from start
to end
(both inclusive).
JavaScript, Math
Calculates the greatest common divisor between two or more numbers/arrays.