sumTo function

int sumTo(
  1. int n
)

Returns the sum of all numbers up to n.

Example:

print(sumTo(5)); // prints: 15

Implementation

int sumTo(int n) {
  return n * (n + 1) ~/ 2;
}