factorial method

int factorial()

Returns the factorial of this integer.

Implementation

int factorial() {
  if (this < 0) throw ArgumentError('Negative numbers are not allowed.');
  var result = 1;
  for (var i = 2; i <= this; i++) {
    result *= i;
  }
  return result;
}