for (int j = 1; j <= k; ++j) {
sign = -sign;
sum += sign * binomialCoefficient(k, j) * ArithmeticUtils.pow(j, n);
if (sum < 0) {
// there was an overflow somewhere
throw new MathArithmeticException(LocalizedFormats.ARGUMENT_OUTSIDE_DOMAIN,
n, 0, stirlingS2.length - 1);
}
}
return sum / factorial(k);
}