## Saturday, April 6, 2013

### How big a number is 400!

The other day I was teaching permutations to my Algebra 2 students, and casually asked how many different arrangements are there for our whole school body to be placed for a picture. I don't know the exact number, but I typically use 400 for estimates (yes -- I make enough estimates for our school that I have a "typical"). I knew immediately that the answer was 400! (which is 400*399*398*...*3*2*1 for those of you who have never seen the ! notation before).

My problem was that I had no concept of just how big 400! really was.  How many digits long is that number?

My initial thinking was to simply type it in the calculator, but it was too big for my TI-84 to handle.  That meant it was more than 100 digits long -- but is it more than 400 digits long? 1000 digits?  How can I answer this?

Eventually I think logarithms will be the answer, but for now let's see if we can set some upper and lower limits on things.  Since each of the digits in the multiplication from 400 down to 1 is less than 3 digits long, then the whole product must be less than 400*3 or 1200 digits long.  Since most of the digits are 2 or more digits long, it's safe to assume it must be more than 400 digits long, but just how many are there?

More formally:
400! = 400*399*398*...*3*2*1 < 1000*1000*1000...  = 1000^400 = (10^3)^400 = 10^1200
400! = 400*399*398*...*12*11*10! > 10*10*10*...*10*10*10! = (10^390)*10!

Now logarithms are a tool our PreCalc students will be tackling this next week, and could be used to answer this question, and it all hinges on the product - sum property of logarithms:
A factorial is simply a lot of multiplications, which would translate into a giant sum of lots of logarithms:

That can be summarized (pun intended...) as:
$log\:400!=\sum_{n=1}^{400}log\:n$
This gives me something that my calculator CAN handle -- since instead of actually trying to display the number, it simply gives me the magnitude of the number. This can be typed into a TI-84 by typing:
sum(seq(log(N),N,1,400)) = 868.8
This means the number 400! is equal to 10^868.8 and is therefore 869 digits long.

A quick check on wolfram alpha verifies this:
(I'm sure some of you were asking "Why didn't he just do that in the first place?" to which I simply respond "Because I didn't have to! God gave me a brain and problem solving skills for a reason!")

As a follow up question -- can I predict how many zeroes are at the end of that number?  In factorials, zeroes come after every multiple of 5.  (Technically, I would need multiples of 2 as well, but there are plenty of those, and relatively fewer multiples of 5).

Up to 4! there are no zeroes:
1, 2, 6, 24,
Between 5! and 9! there is 1 zero:
120, 720, 5040, 40320, 362880
Between 10! and 14! there are 2 zeroes:
3628800, 39916800, 479001600, 6227020800, 87178291200
After that my calculator can't display them properly, but I hope you'll anticipate the pattern.

400 is the 400/5 80th multiple of 5, and so 400! is the first factorial to have 80 zeroes at the end of it.  A not-so-quick check on Wolfram Alpha's picture reveals that there are actually 33*3 or 99 zeroes.  Extras!?

That's because there are more multiples of 5 -- 25, 50, 75, ... 400 each contain 2 factors of 5, and 125, 250, 375 each contain three.  Counting these all up should reveal 99 factors of 5 (and way more factors of 2):
80 Multiples of 5: (5, 10, 15, ..., 390, 395, 400)
16 Multiples of 25: (25, 50, 75, ... 350, 375, 400)
3 Multiples of 125: (125, 250, 375)
99 total factors of 5 therefore 99 zeroes.

And for completeness (since I kept claiming there were way more factors of 2 than 5).
200 Multiples of 2
100 Multiples of 4
50 Multiples of 8
25 Multiples of 16
12 Multiples of 32
6 Multiples of 64
3 Multiples of 128
1 Multiple of 256:
397 Total factors of 2.

What this means is that the prime factorization of 400! contains (among other things) 2^397 and 5^99.
What's the largest prime in 400! is a question for a different night. (Oh, what the heck, why not:)

#### 1 comment:

1. Thanks for this. It gave me an idea of a project for my Algebra 2 class to do.