Calculating log(1000!) 0 ▲ John D. Cook 2 hours ago · Tech · hide · 0 comments The previous post pointed out that the following code such as the following unexpectedly works. >>> from math import log, factorial >>> log(factorial(1000)) 5912.128178488163 If you don’t find this unexpected, note that if you replace math.log with numpy.log the code will fail [1]. Functions like natural logarithm operate on real numbers. Real numbers are represented as floating point numbers in programming languages, and 1000! factorial is too large to represent as a standard floating point number. (More on that here.) In this post I’d like to look at how you might calculate log(1000!) with less capable software, and even without software. One approach would be to sum the logarithms of the numbers 1 through 1000. This will give essentially the same result as above, with a little difference in the last couple decimal places due to rounding error. If you have a way to calculate 1000! but not a way to cast it to a floating point number, you could do this manually. >>> s =… No comments yet. Log in to reply on the Fediverse. Comments will appear here.