# What is the last non-zero digit of $(\dots((2018\underset{! \text{ occurs }1009\text{ times}}{\underbrace{!)!)!\dots)!}}$?

Without using computer programs, can we find the last non-zero digit of $$(\dots((2018\underset{! \text{ occurs }1009\text{ times}}{\underbrace{!)!)!\dots)!}}$$?

What I know is that the last non-zero digit of $$2018!$$ is $$4$$, but I do not know what to do with that $$4$$.

Is it useful that $$!$$ occurs $$1009$$ times where $$1009$$ is half of $$2018$$? If that is useful, then what if $$1009$$ was another value, say $$1234$$?

Any help will be appreciated. THANKS!

• have you tried smaller repeats ? – Roddy MacPhee Aug 26 at 14:45
• @Roddy MacPhee Even doing two factorials is an obscenely large number, a quick wolframalpha search shows $(2018!)! > 10^{10^{5000}}$ – Gabe Aug 26 at 15:00
• smaller inputs @Gabe . With start value 3 I can get $((3!)!)!$ but the next gives me a truncation error in PARI/GP. – Roddy MacPhee Aug 26 at 15:06
• Probably useful: math.stackexchange.com/questions/130352/… – Cheerful Parsnip Aug 26 at 15:18
• or that $10^n!$ has the same last non-zero digit of $(9!)^{10^n-1\over 9}$ – Roddy MacPhee Aug 26 at 15:38

First, note the following: Let $$N$$ be an multiple of 10 i.e., $$N=10k$$. Then the last nonzero digit of $$N!$$ is

a) $$3 \cdot 4 \cdot 6 \cdot 7 \cdot 8 \cdot 9 \equiv _{10}$$ 8 if $$k \equiv_4 1$$;

b) $$8^2$$ mod 10 which is 4 if $$k \equiv_4 2$$;

c) $$8^3$$ mod 10 which is 2 if $$k \equiv_4 3$$; and

d) $$8^4$$ mod 10 which is 6 if $$k \equiv_4 0$$.

Clearly $$(\ldots ((2018!)!)! \ldots ) !$$ is of the form $$10k$$; $$k$$ a multiple of 4. So the last nonzero digit is 6.

• I just ediited @RossMillikan . There was a typo – Mike Aug 26 at 17:44
• If $N$ is of the form $10k$; $k \equiv_4 2$ then the last nonzerto digit is $8^2 \mod_{10}=4$, as I already have down. – Mike Aug 26 at 17:47
• @RossMillikan I did edit to add clarification – Mike Aug 26 at 17:49
• Can you please tell how do you know that $4|k$? – Hussain-Alqatari Aug 27 at 5:45
• If $M$ is an integer at least 40 (which 2018 is of course) then $M!$ is a multiple of 40. So $(2018)!$ is a multiple of 40, as is $((2018)!)!$ (as $2018!$ is clearly at least 40), as is $((2018!)!)!$, and so on and so forth. – Mike Aug 27 at 18:58