John D. Cook 7/28/2026

Inverse factorial improved

Read Original

This article revisits a previous implementation of inverse factorial computation, discussing improvements such as using Newton's method instead of bisection for faster convergence, leveraging the convexity of log gamma on positive reals, and allowing user-specified tolerance. The revised code uses SciPy's gammaln and digamma functions, providing a robust solution for solving equations like floor(log2(n!)) = b. The author explains the rationale behind changes, including returning unrounded results and safer Newton iteration from Stirling's approximation.

Inverse factorial improved

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet