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 !
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.