Finding the number of trailing zeroes in is an elementary and standard approach which gives us the number of zeroes at the end of . But finding the rightmost non-zero digit is one such commonly asked problem that many fewer people know about.
If is sufficiently small, then the units digit of gives us the value of the rightmost non-zero digit of .
Otherwise, we find the units digit of , which we call . Now we solve for . Again, if we arrive at a sufficiently small value of , then we evaluate the units digit of call this and the final answer is .
If such a case doesn't arise, then we keep on iterating for and record the units digit of the product where and are to be followed from the original definition of and call them . Once we arrive at a sufficiently small value for , we find the units digit of call this and the final answer is
Here sufficiently small value for refers to
We first expand as
Now our objective is to collect all the multiples of 5 contained in and group the rest of the terms in groups of four consecutive integers. Note that there will be multiples of 5 in .
We know that in the value of the distribution of lower primes are always greater than or equal to the distribution of higher primes. Thus we know that we can find a multiple (or some higher exponent of 2) from each of the groups of the four consecutive integers which are non-integer multiples of 5.
Also note that for consecutive non-multiples of 5, we have
Now is an even integer for both even and odd . This shows that will be divisible by for all non-negative integers and thus the expression shown above in will be divisible by for all . Hence, the product of four consecutive non-integer multiples of 5, when formulated, will always have 4 in the units place.
So, if we extract all multiples of 2 from each of the given groups of four which are also in number we know that each group will now contribute to a product whose units digit is 2.
Note that if is not sufficiently small, then iterations are to be followed.
The final term shown in comes from the fact that can be of any of the forms and hence may or may not be a part of a group of four. In such a case when it is not in a group of 4, it will be in a group of . For example, if then the groups of 4 are and . The remaining numbers are in which 12 is included in the group of . The multiplication of the integers in the final group that contains will yield a product whose units digit will be equal to the units digit of . This result can be proved using a similar method as in .
This completes our proof.
Find the rightmost non-zero digit of .
Using our method of continued iterations, we have
Combining the above three results, we have
Add an example here.
It is a common exercise to determine the number of trailing zeros of a factorial. For example, 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 is 4, as shown above.
Problem: Find the rightmost non-zero digit of .