All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Factorials (Posted on 2024-05-29) Difficulty: 3 of 5
What decimal digit occurs most often in the sequence of factorials from 77777! to 77877! inclusive?

This can be solved by logic. You do not need to compute any factorials.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution Comment 2 of 2 |
Zero.

The number of trailing zeros in N! is given by the sum of [[N//5^i]]
    where i goes from 0 to [[log(N,5)]], 
    and log(N,5 is log of N base 5, and
    [[]] is greatest integer.

So 77777! ends with 19440 trailing zeros
A little help from a full precision calculator shows that the total number of digits of 77777! is 346621.   So 5.6% of the digits are trailing zeros.
So it is likely that each of factorials of these 5 digit numbers is composed of roughly 15% zeros, with the frequency of each of the other nine digits being roughly 9.4%.
---------

def trail0s(n):
    """  how many zeros at the end of n Factorial? """
    import math
    zeros = 0
    hipower = int(math.log(n,5))
    for p in range(1, hipower + 1):
        zeros += n // 5**p
    return zeros

  Posted by Larry on 2024-05-29 11:18:21
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (2)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information