Computing end-digits of large factorials

  • Thread starter PhDorBust
  • Start date
  • #1
143
0
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.
 

Answers and Replies

  • #2
Ray Vickson
Science Advisor
Homework Helper
Dearly Missed
10,706
1,728
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.
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
143
0
10^12, sorry.

Should it make a difference though?
 
  • #4
SammyS
Staff Emeritus
Science Advisor
Homework Helper
Gold Member
11,358
1,031
10^12, sorry.

Should it make a difference though?
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:
  • #5
143
0
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.
 

Related Threads on Computing end-digits of large factorials

  • Last Post
Replies
4
Views
3K
Replies
3
Views
662
  • Last Post
Replies
7
Views
1K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
8
Views
3K
  • Last Post
Replies
0
Views
1K
  • Last Post
Replies
10
Views
3K
  • Last Post
Replies
9
Views
14K
  • Last Post
Replies
4
Views
1K
  • Last Post
Replies
6
Views
834
Top