# [seqfan] Re: Final nonzero digit of n!.

Fritz Jacob fritzjacob at gmail.com
Sat Apr 17 08:36:35 CEST 2010

```Responses I am getting is that the solution given is very short and cryptic,
please find it below. due to size restrictions, I am sending it in two
emails. I also have an example solution for 93!. Please find Part 1 here.

1) I use RPF here for “Relatively Prime to Five.”

2) N > 1
3) For all divisions “/”, only quotient is considered. Fractions ignored.

***************************************
Solution:
***************************************
Let
P_1 = N/5, (Only quotient)
P_2 = N/(5^2)
P_3 = N/(5^3) and so on till .... ……. P_k = N/(5^k)
Beyond (5^k), higher powers of 5 gives quotient 0.

Let summation of Pi = P

Notice that {N!/(10)^P}(Mod 10) is what we need.
*****************************************

Let RPF(q) indicate the product of first q natural numbers, which are
relatively prime to 5.
Let RemRPF(q) indicate the reminder(when divided by 10) of first q natural
numbers, which are relatively prime to 5.

Example RPF(11) = (1*2*3*4*6*7*8*9)*(11*12*13)
---------------------------------------------------------------------------(1)
It can be easily observed that RemRPF(q) is repetitive from RemRPF(9)
onwards.

For example
{ RemRPF(9) , RemRPF(10)….. RemRPF(16)}

= { RemRPF(17) , RemRPF(18)….. RemRPF(24)}

= {6,2,6,4,4,8,4,6}
----------------------------------------------------------------------------------------------------------------------(2)

Since it is repetitive, from (2), it can be seen that

[RemRPF(q)](Mod 10) = [RemRPF(q(Mod 8))](Mod 10)
-----------------------------------------------------------------------------(3)

Note that in (3), treat RemRPF(1) = 6, instead of 1. And also RemRPF(0) =
RemRPF(8).

To be Contd in next email......

```