I can't solve it myself.

Find the last non-zero digit of

2000 ! \large 2000!

Notation: ! ! denotes the factorial notation . For example: 8 ! = 1 × 2 × 3 × 4 × 5 × 6 × 7 × 8 8! = 1 \times 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 .

6 4 8 2

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.

3 solutions

Chris Lewis
Jul 29, 2020

There are some interesting discussions of the general sequence of last non-zero digits of n ! n! at the OEIS, here .

If you're just interested in a way to find the last non-zero digit of 2000 ! 2000! , we can do it with an algorithm.

First, it's worth noting that simply computing 2000 ! 2000! 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 k digits of 2000 ! 2000! algorithmically; we just calculate the sequence a 1 = 1 a_1=1 , a n = Mod ( n a n 1 , 1 0 k ) a_{n}=\text{Mod} \left(n a_{n-1},10^k \right)

where Mod ( p , q ) \text{Mod} (p,q) is the remainder when p p is divided by q q .

How many digits do we need to retain for 2000 ! 2000! ? We quickly start adding zeros onto the end of the factorials; in fact, 2000 ! 2000! has 499 499 ending zeros, so we could do this with k = 500 k=500 . 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 ! n! increases exactly when n n is a multiple of 5 5 (why is this?). If n n is a multiple of 5 5 , but not 25 25 , n ! n! has one more ending zero than ( n 1 ) ! (n-1)! . If n n is a multiple of 25 25 , but not 125 125 , n ! n! has two more ending zeros than ( n 1 ) ! (n-1)! , and so on.

So we need to know the highest power of 5 5 that divides n n . This is usually written as ν 5 ( n ) \nu_5 (n) .

The largest power of 5 5 less than 2000 2000 is 5 4 = 625 5^4=625 . So 625 ! 625! has 4 4 more ending zeros than 624 ! 624! , and this is the worst case. Therefore we need to retain just 5 5 ending digits - ie we need k = 5 k=5 .

Finally, we can modify the sequence above as follows: let a 1 = 1 a_1=1 and a n = 1 1 0 ν 5 ( n ) Mod ( n a n 1 , 1 0 5 ) a_{n}=\frac{1}{10^{\nu_5 (n)}} \text{Mod} \left(n a_{n-1},10^5 \right)

This is easy to implement in code (or Excel), and will give the correct final non-zero digit of n ! n! for all n < 5 5 = 3125 n<5^5=3125 . In particular, we find the last non-zero digit of 2000 ! 2000! is 8 8 .

Hopefully this makes sense as a simple(ish) approach - there are much deeper discussions in the site linked above.

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!

Vinayak Srivastava - 10 months, 2 weeks ago

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 n to see what patterns you can find.

Let me know if there's anything I can make clearer in the explanation.

Chris Lewis - 10 months, 2 weeks ago

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!

Vinayak Srivastava - 10 months, 2 weeks ago

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 ! n! will be the same as that of 2 n 5 × n 5 ! × ( n ( m o d 5 ) ) ! \Large{2^{\left\lfloor{\dfrac{n}{5}}\right\rfloor} \times {\left\lfloor{\dfrac{n}{5}}\right\rfloor}! \times (n \pmod{5})!}

Vinayak Srivastava - 10 months, 2 weeks ago

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?

Chris Lewis - 10 months, 2 weeks ago

Log in to reply

I'll definitely try!

Vinayak Srivastava - 10 months, 2 weeks ago

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!

Vinayak Srivastava - 10 months, 2 weeks ago
Ahmed Pro
Jul 31, 2020

Well i noticed that the last digit in 10! Is 8

  • And for make it easy! Lets say L(x)=the last non zero digit

Because L(10!)=8 So L((2×10)!)=L( 8 2 8^2 )=4

L((3×10)!)=L( 8 3 8^3 )=L(512)=2

Obviously that mean

  • L ( ( n × 10 ) ! ) = L ( ( 8 n ) ) \boxed{L((n×10)!)=L((8^n))} , Notice that L ( 8 5 ) = 8 \boxed{L(8^{5})=8} so we back again from we start

Now we can get L ( 2000 ! ) \color{#D61F06}{L(2000!)}

  • L(2000!)=L((200×10)!)=L(( 8 200 8^{200} notice that 200 is divisible bye 5, so we back again to L(8^5) Which is =8

  • So L ( 2000 ! ) = 8 \boxed{L(2000!)=8}

Sorry, you code isn't working. Also, you need the last digit of 2000!, not 200!

Vinayak Srivastava - 10 months, 2 weeks ago

the solution is right but i made so many mistakes in writing

Ahmed Pro - 10 months, 2 weeks ago

i am stupid sorry now it should work perfectly :)

Ahmed Pro - 10 months, 2 weeks ago

I am not perfectly able to understand the formula, @Chris Lewis , Sir, can you please see this?

Vinayak Srivastava - 10 months, 2 weeks ago

Log in to reply

I'm confused too. The solution seems to say L ( 20 ! ) = 6 L(20!)=6 and L ( 30 ! ) = 2 L(30!)=2 but it's easy to check (eg Wolfram|Alpha, or the OEIS page I referenced) that these two values should be 4 4 and 8 8 respectively.

Chris Lewis - 10 months, 2 weeks ago

you did not know how it is work or did not understand it?

Ahmed Pro - 10 months, 2 weeks ago

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

Ahmed Pro - 10 months, 2 weeks ago

Log in to reply

But you still have L ( 30 ! ) = 2 L(30!)=2 , which is wrong as I mentioned above. The OEIS entry here has a table of values of L ( n ! ) 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 8 is periodic with period 4 4 (they just cycle through 8 , 4 , 2 , 6 , 8 , 4 , 2 , 6 , 8,4,2,6,8,4,2,6,\cdots ) but the sequence L ( ( 10 k ) ! ) L((10k)!) definitely isn't; the first few (from the table above) are 8 , 4 , 8 , 2 , 2 , 6 , 8 , 8 , 8,4,8,2,2,6,8,8,\cdots .

Chris Lewis - 10 months, 1 week ago

You are right i correct it like you can see there

Ahmed Pro - 10 months, 1 week ago
Iliya Hristov
Aug 8, 2020

I don't understand the pattern. Please explain.

Vinayak Srivastava - 10 months, 1 week ago

Log in to reply

I finally edited my mess and this time I tried to prove your formula.

Iliya Hristov - 8 months, 2 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...