# Homework Help: Computing end-digits of large factorials

1. Oct 31, 2011

### PhDorBust

The factorial of 1 trillion ends in many trailing zeros. Find the five digits that comes before the trailing zeros.

I know how to calculate the number of trailing zeros, but don't know what to do afterwards. This is a computational problem.

2. Oct 31, 2011

### Ray Vickson

One trillion could be either 10^12 or 10^18, depending on where you reside. Which one do you mean? See http://en.wikipedia.org/wiki/Trillion .

RGV

3. Oct 31, 2011

### PhDorBust

10^12, sorry.

Should it make a difference though?

4. Oct 31, 2011

### SammyS

Staff Emeritus
It will make a huge difference. But, it may not make a difference in the final 5 non-zero digits.

Do you know how many trailing zeros there are in (1012)! ?

Last edited: Oct 31, 2011
5. Nov 1, 2011

### PhDorBust

Let a = 10^12, b = n be largest n such that a/5^n is an integer.

Number of trailing zeros will be N = a/5 + a/(5^2) + a/(5^3) + ... a/(5^n) = a/(5^n) * (1 + 5 + 5^2 + ... + 5^(n-1) ) = a/(5^n) * [ 5^n - 1] / [5 - 1].

But (10^12)! / 10^N is still pretty damn large to calculate. I don't see the next step.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook