When $40!$ is expressed in base $8$ form, what is the last non–zero digit in the base $8$ expansion?

1.5k Views Asked by At

For this problem I have figured out that the number of trailing zeros will be $12$ if the $40!$ will be written in base $8$ but how can we go ahead to find the last non-zero digits after which the trailing zeroes start.

Please help me on this ! I have been stuck at this problem for a while.

Thanks in advance !

2

There are 2 best solutions below

2
On

Count the factors of $2$ in this factorial. Using the standard formula:

$\lfloor{\frac{40}{2}}\rfloor+\lfloor{\frac{40}{4}}\rfloor+...+\lfloor{\frac{40}{32}}\rfloor=20+10+5+2+1=38$

This is two greater than a multiple of $3$, so the number is $4×\text{ ( an odd number ) }×8^k$ for some whole number $k$.

So the last nonzero digit in base 8 can only be 4.

1
On

There is a very useful formula for this kind of problems. If $p$ is prime, then the greatest exponent $r$ such that $p^r$ divides $n!$ is $$r=\sum_{k=1}^{p^k>n}\left\lfloor\frac n{p^k}\right\rfloor$$ So take $p=2$ and $n=40$. Then $$r=\left\lfloor\frac {40}{2}\right\rfloor+\left\lfloor\frac {40}{4}\right\rfloor+\left\lfloor\frac {40}{8}\right\rfloor+\left\lfloor\frac {40}{16}\right\rfloor+\left\lfloor\frac {40}{32}\right\rfloor=20+10+5+2+1=38$$ Since $38=12\cdot 3+2$, the number of trailing zeros is indeed $12$, but $40!/2^{36}$ is still a multiple of $4$ (but not of $8$), so the last nonzero digit is $4$.