4 ms·
"Again, no recursion is required as long as one knows that a factorial is actually a special case of the gamma function. (The implementation of log-gamma is usu
by jdkee 4y ago
"Again, no recursion is required as long as one knows that a factorial is actually a special case of the gamma function. (The implementation of log-gamma is usually a polynomial approximation which requires constant time to evaluate.)"
A prime idea behind using recursive techniques is that for many complex problems you do not have to know the "special case" as you can break complex problems into simpler pieces that can be solved via recursion.
- adalacelove 4y agoI would be surprised if there is not some kind of loop in the code that is used to evaluate the gamma function. You can also define factorial like for example the number of different permutations of any set of a given size.
- texaslonghorn5 4y agooutside of edge cases, c++ lgamma (log of gamma) uses Lanczos iteration with 8 iterations and gamma is just exp(lgamma)