3

Wolfram|Alpha Factorial Trick

Published on Thursday, December 08, 2011 in , , ,

Wolfram|Alpha knowledge engine5 months ago, I posted my first Wolfram|Alpha trick. The time for the second one has come!

We start with a helpful lead-in from NumberPhile.

In mathematics, a factorial is simply the product of a positive integer (whole number) n multiplied by all the other positive integers less than n. 4 factorial, for example, would be equal to 4 times all the positive whole numbers less than 4, or 4 × 3 × 2 × 1 = 24. So, 4 factorial would be 24.

Instead of writing the word “factorial”, though, mathematicians use the exclamation point (!). So, 4! = 24 would be read verbally as “4 factorial equals 24”.

Do you have a guess as to the biggest number for which the average pocket calculator can determine the factorial? Here's the answer:



Thankfully, today we have tools like Wolfram|Alpha, so figuring 70! can be done in not only scientific notation, but in the form of regular numbers: 11,978,571,669,969,891,796,072,783,721,689,098,736,458,938,142,546,425,857,
555,362,864,628,009,582,789,845,319,680,000,000,000,000,000 (or, just a little over a googol).

Besides getting larger at an ever-increasing rate (not surprising, consider how they're calculated), it's also easy to notice that there's lots of trailing zeroes (zeroes at the end). If you think about it, this isn't surprising, since roughly half the numbers in any factorial equation will be even numbers, and anytime one of those is multiplied by a 5, you'll get a multiple of 10 that adds another 0.

5! = 120, which is where we find our first zero. When will the next zero show up? Let's take a look:

6! = 720
7! = 5,040 (Hmmm...we have another zero, but it's not a trailing zero.)
8! = 40,320
9! = 362,880
10! = 3,628,800 (Aha! We just got our 2nd trailing zero!)
So, 10! is when the second trailing zero shows up. That makes sense, another multiple of 5 adds another zero! Also, notice that 10/5 = 2, which gives us the number of trailing zeroes. Does that mean that 15! is the first number with 3 trailing zeroes?

To work this out, we figure 14! = 87,178,291,200, and note that it still has 2 trailing zeroes. Since 15! = 1,307,674,368,000 has 3 trailing zeroes, we seem to have discovered a simple pattern.

Using that knowledge, how many trailing zeroes would you guess are in 21!? The nearest multiple of 5 equal to or lesser than 21 is 20, and 20/5 = 4, so there should be 4 trailing zeroes. Sure enough, 21! = 51,090,942,171,709,440,000 and we can even have Wolfram|Alpha tell us the number of trailing zeroes without doing the calculation.

Try figuring out how many trailing zeroes come after 28!. Going by the above pattern, it seems like it should be 5 trailing zeroes, but Wolfram|Alpha says it's 6! Well, 28! = 304,888,344,611,713,860,501,504,000,000, and there are definitely 6 zeroes. What happened?

The hitch is that we passed the number 25, which is 5 × 5, so we're actually getting an extra five for every multiple of 25 (25, 50, 75, 100...). We'll run into a similar problem when figuring factorials on and after 125!, since that is 5 × 5 × 5.

The trick to finding the number of trailing zeroes for a given factorial is to figure out how many multiples of 5 there are, then how many multiples of 25 are in the given number, and how many multiples of 125. If you're using larger numbers, then you'd have to work out how many multiples of 625, 3,125, and so on were included.

Here's how to impress someone with this fact and online access to Wolfram|Alpha. Briefly explain the basics of factorials and their trailing zeroes, showing them with lower numbers like 7! and 11! how quickly such numbers get large, and how the trailing zeroes increase. Also, show them that Wolfram|Alpha can calculate the number of trailing zeroes, as well.

Ask them for a number from 1 to 200, and bet that you can get at least as close to the number of trailing zeroes for the factorial of any number they give, if not closer.

Let's say the person gives the number 36. You first think that the closest multiple of 5 equal to or lower than 36 is 35, and 35/5 = 7. Also, 36 is higher than 25, so add 1 for the number of “25s” that are equal to or less than 36. That 7 (the number of 5s) plus 1 (the number of 25s) = 8, so all you have to do is bet that there are 8 trailing zeroes in 36!. Sure enough, there are 8 trailing zeroes in 36! (here's the actual total, if you're curious).

How about 61!? There's 12 fives and 2 twenty-fives (2 × 25 = 50), so 61! should have 12 + 2 = 14 trailing zeroes.

By limiting the numbers given up to 200, you'll be able count the number of 125s in a number simply enough (It's either 1 or 0). You'll also need to know your multiples of 25 up to 200 (25, 50, 75, 100, 125, 150, 175, 200).

You'll also be able to divide any number up to 200 by 5. Fortunately, there's an easy way to do this in your head, as taught in this short video:



This also works with 2 digit numbers, as long as you're comfortable doubling numbers up to 200. For the purposes of the Wolfram|Alpha Factorial Trick, this can be made even easier! First, double the number as in the video, then just drop the number in the ones place!

How many trailing zeroes in 117!? To figure the number of 5s, we double 117 to get 234, and just drop the number in the ones place, giving us 23 (23 × 5 = 115), so there are 23 fives. There's also 4 twenty-fives in 117 (4 × 25 = 100), and no 125s in that number, so we have 23 + 4 + 0 = 27 trailing zeroes!

As a final example, how about 134!? Think: 134 × 2 = 268 = 26 (with 8 dropped off) fives, plus 5 twenty-fives, plus 1 one-hundred-twenty-five = 32 trailing zeroes. Is that right? It sure is!

I first ran across this feat in Nerd Paradise, where you can turn for further explanation. I find that the use of Wolfram|Alpha and the limitation of numbers from 1 to 200 make this easier to present and perform, however.

Let me know if you try it and get any interesting responses!

Spread The Love, Share Our Article

Related Posts

Post Details

3 Response to Wolfram|Alpha Factorial Trick

Jay
1:37 PM

This is great, I love feats like this. I'm not a mathematician (just a simple calculator) but do you know if there is a complicated formula for finding the trailing zeros? Sometimes when I do complex calculations I like to show the spectators the complex formula used. Then I blow their minds using some kind of shortcut or trick. This would be a good presentational ploy. Thanks

George
9:26 AM

The number of trailing zeroes, n(x), of the number x! is given by:

n(x) = sum[IntegerPart[x/(5^n)], {n,1,infinity]

This formula looks much better in ordinary notation but I can't do that here.

Anonymous
1:00 AM

This is really good! This page is nice too:


Calculate Trailing zeros in factorial