It is a common exercise to determine the number of trailing zeros of a factorial . For example, 2 0 ! = 2 4 3 2 9 0 2 0 0 8 1 7 6 6 4 0 0 0 0 has 4 trailing zeros (as highlighted in green above).
However, finding the rightmost non-zero digit of a factorial is much harder. For example, the rightmost non-zero digit of 2 0 ! is 4, as shown above.
Problem: Find the rightmost non-zero digit of 1 0 0 0 0 ! .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I have published a wiki for evaluating one. :)
That was great..How did you work that out?
Log in to reply
Just some work. I've added my work in the proof too.
just see and multiply ten numbers from 1 until 10, like as : 1.2.3.4.5.6.7.8.9.10 and the rightmost non-zero is 8
Not quite. You have to watch out for the number of factors of 2 and 5 and account for them accordingly.
This is incorrect. By your logic, you would have answered 8 for the number 1 0 0 ! as well, when in fact, the answer should be 4.
Log in to reply
Is there a non-tedious solution? I just plugged 1 0 2 4 9 9 1 0 0 0 0 ! m o d 1 0 into WolframAlpha.
Log in to reply
Non-tedious? Not really. But I know a systematic approach. Hint: Find the last non-zero digit of ∏ j = 0 9 ( 1 0 k + j ) , where k is any arbitrary positive integer. Now what do you observe?
Log in to reply
@Pi Han Goh – I don't see a pattern.
Log in to reply
@Jesse Nieminen – I doubt there is an obvious pattern. The answer depends on how which powers of 5 we've hit along the way.
IE
1
0
!
has last digit 8,
2
0
!
has last digit
8
×
8
≡
4
,
3
0
!
"should" have a last digit of
4
×
8
=
3
2
, but because there is an additional multiple of 5 in 25, hence we get
3
2
×
5
=
1
6
0
so a last digit of 6 instead.
4
0
!
has a last digit of
6
×
8
≡
8
,
5
0
!
"should" have a last digit of
8
×
8
≡
6
4
, but because here is an additional multiple of 5 in 50, hence we get
6
4
×
5
=
3
2
0
so a last digit of 2 instead.
It is in accurately tracking these multiples of 5 (and hence 2) that it gets tricky to evaluate. IE When we get up to multiples of 125, 625, 3125, etc, the "pattern" changes again.
@Jesse Nieminen – Ah sorry, my hint is toooo obscure. Here's the answer or click here .
Maybe someone should write a wiki about this. Let me see if I conjure up a clear way of explaining this thing.
Problem Loading...
Note Loading...
Set Loading...
I could't work out any recursive formula or closed form for n but here is the working process.
Define x ∈ N such that 5 x ≤ n < 5 x + 1 .
∀ a ∈ N , a ≤ x Find ⌊ 5 a n ⌋ ( m o d 1 0 ) , call it b a
Assign the values as follows , call it d a
b a 1 2 3 4 5 6 7 8 9 0 d a 1 2 1 4 4 4 3 4 1 1
Evaluate : a = 1 ∏ a = x d a , call the value obtained to be t
Evaluate the number of trailing zeroes in n ! , say m .
Evaluate y ( m o d 5 ) such that 2 m × y ≡ t ( m o d 5 )
The desired answer is y + 5
For the given problem :
x = 5 , t = 4 , m = 2 4 9 9 , y = 3 ⇒ 8 is the required answer.