sumTo method

num sumTo(
  1. num other
)

Calculates the sum of all numbers in the range from the current number to other, inclusive.

Example:

print(1.sumTo(5)); // Outputs: 15 (1+2+3+4+5)

Implementation

num sumTo(num other) => rangeTo(other).reduce((value, element) => value + element);