Find the last non-zero digit of
2 0 0 0 !
Notation: ! denotes the factorial notation . For example: 8 ! = 1 × 2 × 3 × 4 × 5 × 6 × 7 × 8 .
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 think I can understand most of it, if I re-read 2-3 times, I will understand. Thank you for your solution, Sir! This problem seems to be more interesting than I had thought it would be!
Log in to reply
Same here - I thought mine was going to be a short answer but clearly I was wrong! Perhaps there is an easier way I missed.
I'd recommend experimenting with smaller values of n to see what patterns you can find.
Let me know if there's anything I can make clearer in the explanation.
Log in to reply
Ok, I'll try to see if I can find some pattern. If I can't understand something, I will ask you. Thanks!
Sir, I found a website( link ) which has a recursive formula to find the last non-zero digit of any factorial number! Please see this!
In short, it states that the last non-zero digit of n ! will be the same as that of 2 ⌊ 5 n ⌋ × ⌊ 5 n ⌋ ! × ( n ( m o d 5 ) ) !
Log in to reply
Very nice!! That's a lot easier to implement. The link you posted doesn't show a derivation or explanation of this formula, though - can you find one?
Log in to reply
I'll definitely try!
Oh, I forgot to search on Brilliant itself! There is a wiki on this type of problems, it also contains the proof. I think it involves some higher mathematics which I haven't studied, but this formula is great!
Well i noticed that the last digit in 10! Is 8
Because L(10!)=8 So L((2×10)!)=L( 8 2 )=4
L((3×10)!)=L( 8 3 )=L(512)=2
Obviously that mean
Now we can get L ( 2 0 0 0 ! )
L(2000!)=L((200×10)!)=L(( 8 2 0 0 notice that 200 is divisible bye 5, so we back again to L(8^5) Which is =8
So L ( 2 0 0 0 ! ) = 8
Sorry, you code isn't working. Also, you need the last digit of 2000!, not 200!
the solution is right but i made so many mistakes in writing
i am stupid sorry now it should work perfectly :)
I am not perfectly able to understand the formula, @Chris Lewis , Sir, can you please see this?
Log in to reply
I'm confused too. The solution seems to say L ( 2 0 ! ) = 6 and L ( 3 0 ! ) = 2 but it's easy to check (eg Wolfram|Alpha, or the OEIS page I referenced) that these two values should be 4 and 8 respectively.
you did not know how it is work or did not understand it?
you are right i calculated 8 square wrongly the last digit in 8 square is 4 i fixed it know i hope you see what i mean
Log in to reply
But you still have L ( 3 0 ! ) = 2 , which is wrong as I mentioned above. The OEIS entry here has a table of values of L ( n ! ) here so you can check if your method works.
I have to say I'm not at all sure it will - the sequence of final digits of powers of 8 is periodic with period 4 (they just cycle through 8 , 4 , 2 , 6 , 8 , 4 , 2 , 6 , ⋯ ) but the sequence L ( ( 1 0 k ) ! ) definitely isn't; the first few (from the table above) are 8 , 4 , 8 , 2 , 2 , 6 , 8 , 8 , ⋯ .
You are right i correct it like you can see there
I don't understand the pattern. Please explain.
Log in to reply
I finally edited my mess and this time I tried to prove your formula.
Problem Loading...
Note Loading...
Set Loading...
There are some interesting discussions of the general sequence of last non-zero digits of n ! at the OEIS, here .
If you're just interested in a way to find the last non-zero digit of 2 0 0 0 ! , we can do it with an algorithm.
First, it's worth noting that simply computing 2 0 0 0 ! is not the way to go. It is - obviously - huge, and has many more digits than we're interested in. However, it's fairly easy to compute the last k digits of 2 0 0 0 ! algorithmically; we just calculate the sequence a 1 = 1 , a n = Mod ( n a n − 1 , 1 0 k )
where Mod ( p , q ) is the remainder when p is divided by q .
How many digits do we need to retain for 2 0 0 0 ! ? We quickly start adding zeros onto the end of the factorials; in fact, 2 0 0 0 ! has 4 9 9 ending zeros, so we could do this with k = 5 0 0 . But this is still a huge calculation.
We can reduce the number of digits needed by ignoring ending zeros.
Now note that the number of ending zeros of n ! increases exactly when n is a multiple of 5 (why is this?). If n is a multiple of 5 , but not 2 5 , n ! has one more ending zero than ( n − 1 ) ! . If n is a multiple of 2 5 , but not 1 2 5 , n ! has two more ending zeros than ( n − 1 ) ! , and so on.
So we need to know the highest power of 5 that divides n . This is usually written as ν 5 ( n ) .
The largest power of 5 less than 2 0 0 0 is 5 4 = 6 2 5 . So 6 2 5 ! has 4 more ending zeros than 6 2 4 ! , and this is the worst case. Therefore we need to retain just 5 ending digits - ie we need k = 5 .
Finally, we can modify the sequence above as follows: let a 1 = 1 and a n = 1 0 ν 5 ( n ) 1 Mod ( n a n − 1 , 1 0 5 )
This is easy to implement in code (or Excel), and will give the correct final non-zero digit of n ! for all n < 5 5 = 3 1 2 5 . In particular, we find the last non-zero digit of 2 0 0 0 ! is 8 .
Hopefully this makes sense as a simple(ish) approach - there are much deeper discussions in the site linked above.