sumRange static method

int sumRange(
  1. int n
)

Calculates the sum of numbers from 1 to n.

Implementation

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