?>

# Department of Science, Math, & Technology

E = mc�
How many digits?
Posted: Posted July 27th, 2018
Edited July 27th, 2018 by The Fly
 Hi Friends, How many digits does 7000! have? (That's 7000 factorial, by the way: 7000 times 6999 times 6998 times 6997 etc ... all the way down to 3 times 2 times 1.) Its a very large integer, I don't know how many digits it has exactly, but one could start by an approximation. All the best, The Fly
There are 10 Replies

Google makes this one almost too easy. All I had to to was google "7000 factorial" (I'd tried "7000!" and it treated the ! as punctuation) and it gave me this website:
https://coolconversion.com/math/factorial/What-is-the-factorial-of_7000_%3F
...which not only gives you the number of digits but actually gives you the actual value, all 23,878 digits of it.

Sorry to be a buzzkill.

Posted July 27th, 2018 by Black Yoshi
View Source Quote Report

You've been given speeding ticket for this! Google is not allowed. We need a mathematical argument calculating it.

Posted July 27th, 2018 by The Fly
View Source Quote Report

4 digits

Posted July 27th, 2018 by Brandy
View Source Quote Report

Ah, damn, sorry. Mathematical proofs are somewhat over my head, to be honest. I'll leave this one to those who know what they're doing. At least I've given them a value to compare to, right?

Posted July 28th, 2018 by Black Yoshi
View Source Quote Report

I actually did a bit of work on something like this for a project I'm calling "the really bad calculator".

It seems like when you multiply two 4-digit numbers together, you get something that either has 7 or 8 digits:

• 9999*9999 = 99,980,001 (8)
• 1000*1000 = 1,000,000 (7)

I wanted to see what the exact range was, so I started by making guesses at the halfway point between them and going from there (that's how square roots are calculated, iirc). Then I realized, there's an easier way -- find the smallest 8-digit number and take the square root of it.

• sqrt(10,000,000) = ~3162

This sequence of digits holds for multiplying other numbers of digits together as well:

• NNNN*NNNN = sqrt(10,000,000) = ~3162
• NNN*NNN = sqrt(100,000) = ~316.2
• NN*NN = sqrt(1000) = ~31.62
• N*N = sqrt(10) = ~3.162

Given this, you can come up with a generalized form:

• Let n be a number with d digits.

For n2:

• If n < sqrt(10^(2d-1)): dnew = 2d-1
• If n >= sqrt(10^(2d-1)): dnew = 2d

Multiplying a number by its successor (ex -- 6998*6999) is pretty close to just multiplying a number by itself. So when evaluating 7000!, you end up with the following approximation:

• 1. (6999-3162)/2 8-digit factors
• 2. (3162-1000)/2 7-digit factors
• 3. (999-316)/2 6-digit factors
• 4. (316-100)/2 5-digit factors
• 5. (99-32)/2 4-digit factors
• 6. (31-10)/2 3-digit factors
• 7. (9-3)/2 2-digit factors
• 8. (2-1)/2 1-digit factors

Since you can multiply factors using the same formula above, you could simplify #1 further:

• 1a. (6999-3162)/2 8-digit factors
• 1b. (6999-3162)/4 15/16-digit factors
• 1c. (6999-3162)/8 29/32-digit factors

Unfortunately this starts to spread out and also doesn't really help with what you're trying to solve. Maybe a better way is to generalize the 3162 formula into something more useful that can describe the exact problem.

Intuitively I have an idea that if I can find an upper bound and a lower bound on the number of digits for 7000!, I can use the 3162 ratio to pinpoint how many digits there actually are somehow. I'll need to do some more work on this.

• Posted July 28th, 2018 by Xhin
View Source Quote Report
Xhin

7000! < 10000! < 10000^10000 = (10^4)^10000 = 10^40000

So a VERY loose upper bound is 1 with 40000 zeros after it.

At least it's the right order of magnitude for the answer that Black Yoshi gave.

Posted August 4th, 2018 by EN
View Source Quote Report

Funny thing is, I actually got pretty damn close just by counting the number of instances of 10 that would arise if you factored out all 7,000 numbers. No, I didn't actually factor all 7,000 numbers out, that would take years; instead, I estimated based on the order of magnitude.

So, we know that 10! (or 3,628,800) has seven digits (so, 6 tens in total). Every number from 11 to 99, when multipled in, should add one power of ten, or 89, leaving us with 95 total.

Every number from 100 to 999 should add two powers of ten; there are 900 numbers, so 900x2 = 1800, giving us 1895 total.

Every number from 1000 to 7000 should add three powers of ten; there are 6001 total, so 6001x3 = 18003, 18003 + 1895 gives us 19898 total.

But we're not done. 10 = 5 x 2, so we have to factor in all the multiples of 5 in there as well...and the multiples of the powers of 5, if any exist. So, in total, there are 7000/5 = 1400 multiples of five. Of those, 1400/5 = 280 are multiples of 25. Of those, 280/5 = 56 are multiples of 125. So, 19898 + 1400 + 280 + 56 (that is, 19898 multiples of ten, plus 1400 multiples of five, plus 280 additional fives for multiples of 25, plus 56 additional fives for multiples of 125) = 21,634 total powers of 10, or 21,635 digits.

I actually got even closer when I erroneously took the 19898 number, thought that represented the number of numbers, divided it by five, and then added that back to the original, so:

19898 + (19898/5) = 23877.6, round up to 23878 because you can't have part of a digit, add one to get 23,879.

...huh...I'd actually made a math error beforehand when I'd done this, and now that I've corrected it I'm actually even closer. I've no idea how that works so well, but it works.

Edited August 8th, 2018 by Black Yoshi
View Source Quote Report

I actually got even closer when I erroneously took the 19898 number, thought that represented the number of numbers, divided it by five, and then added that back to the original, so:

19898 + (19898/5) = 23877.6, round up to 23878 because you can't have part of a digit, add one to get 23,879.

...huh...I'd actually made a math error beforehand when I'd done this, and now that I've corrected it I'm actually even closer. I've no idea how that works so well, but it works.

Actually, it turns out that this is only a one-time deal that works right around the 7000! mark; any other x! will deviate from this value some, depending on how far x is away from 7000!. To get the real answer would actually require factoring out every non-prime value in the entire set, and then examining all of those prime factors to see if any of them is greater than ten, and factoring in as necessary.

Posted August 8th, 2018 by Black Yoshi
View Source Quote Report

This was kind of fun to work on over lunch. ^__^

There are probably more efficient algorithms to calculate the number of digits with log, but short of actually calculating it I did this:
[bigint]$f=1;7000..1|%{$f*=$_};$f.ToString().Length

23878 digits. Outputting $f will show the entire number.$f.ToString().Length is just a lazy, but also an easy and light built in way of counting the number of digits in Powershell. We just step through every number from 7000 to 1 (7000..1) and multiply/add each iteration between those numbers.

For the actual number (Edit: expanding this will break the table on GT so just refresh page to collapse).

Edited August 17th, 2018 by LLight
View Source Quote Report

4 digits

That’s right.
4 digits and 1 punctuation mark.
Or, 4 digits and 9 letters.

————-

You can estimate a lower bound as follows.
From 1000 up to 7000 you have 6001 4-digit factors. So there’s at least 6001*3 + 1 = 18004 digits.
From 100 up to 999 you have 900 3-digit factors. Their product is at least 900*2 + 1 = 1801 digits.
From 10 up to 99 you have 90 2-digit factors. Their product has at least 91 digits.
9! is 362,880 —— 6 digits.

So the product will have at least 18003 + 1800 + 90 + 5 + 1 = 19899 digits.

And we know that’s an underestimate because every time the new factor passes a multiple of 5 the product should pick up an extra digit. 19899 + 1400 is 21299. That’s pretty close to what Google said.

And I haven’t looked at Google.

Did you try approximating with Stirling’s formula?

[EDIT]: It looks like Black Yoshi and others already did this, and I somehow failed to see it before posting. So, consider me endorsing their work. It seems the only thing new I contributed was the mention of Stirling’s formula! [/EDIT]

Edited April 22nd, 2019 by chiarizio
View Source Quote Report