Hi, I recently submitted an issue to JIRA ( https://issues.apache.org/jira/browse/MATH-1293) and received an advice to discuss it here.
In short, the current implementation of CombinatoricsUtils#factorialLog employs direct summation and thus has linear complexity (O(n) additions and O(n) logs). I suggest replacing it with a tabulated lookup. This solution will need to allocate some additional memory, but the speed-up for larger n would be tremendous. For the values that are too large to be looked up, equivalent Gamma#logGamma is still much faster than the existing algorithm. I attached a proposed patch to the issue. However, there are a lot of details that need to be worked out, first and foremost whether such optimization is at all worth it. Thus I ask for your opinion. Please let me know what think. Sincerely, Aleksei Dievskii.