Associated Topics || Dr. Math Home || Search Dr. Math

### Number of Digits in a Factorial

```Date: 09/18/2005 at 13:37:48
From: Ryan
Subject: Number of digits in a factorial?

Is there a way to determine the number of digits that result from a
factorial?  For instance, 3! = 6 so there is 1 digit.  But what about
something much larger like 125!?  Is there any possible way to tell
the number of digits in the answer?

```

```
Date: 09/18/2005 at 18:38:51
From: Doctor Vogler
Subject: Re: Number of digits in a factorial?

Hi Ryan,

Thanks for writing to Dr. Math.  The number of digits in the positive
integer x is exactly

log(x) + 1,

rounded down, where the log is base 10, or you could write

ln(x)/ln(10) + 1,

rounded down.  (Of course, if x is not a perfect power of 10, then
this is the same as log(x) rounded up.)

Next all you need is a good enough approximation that rounding off
gives you the right answer.  For that, you can use Stirling's Theorem,

Stirling's Approximation
http://mathforum.org/library/drmath/view/55996.html

Take the log of both the upper and the lower bounds, add 1, and round
both down to the nearest integer.  If you get the same number on both

back and show me what you have been able to do, and I will try to
offer further suggestions.

- Doctor Vogler, The Math Forum
http://mathforum.org/dr.math/

```

```
Date: 09/19/2005 at 11:25:41
From: Ryan
Subject: Thank you (Number of digits in a factorial?)

That works great - thank you very much for your help Doctor Vogler!

Cheers,

Ryan
```
Associated Topics:
High School Number Theory

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search