As the title says, I'm looking for the last $500$ digits of $2015!-1$. I assume it's a repetition of zeroes from the factorial, so the final result is a lot of $9$-s, but I can't formulate a solution in a mathematical way. I know that $201$ zeroes come from $10$-s in there, also, $202$ from the $5$-s that are multiplied by even numbers, $20$ extra from the $100$-s, $2$ more from the $1000$-s, but I'm still missing a couple.
-
4How many times can $5$ divide into $2015!$? – Element118 Jan 10 '16 at 23:21
-
3Are you sure that's all? How about $25$? – Element118 Jan 10 '16 at 23:23
-
I'd say that 2015! has 486 zeroes at the end, but the rest of the 14 numbers you ask, are the difficult part – Nikunj Jan 10 '16 at 23:30
-
2@Nikunj $2015!$ has exactly $502$ zeroes at the end. – user236182 Jan 10 '16 at 23:31
-
4Legendre's Formula solves this. It's essentially what Snow did in the answer. – user236182 Jan 10 '16 at 23:33
-
Related : http://math.stackexchange.com/questions/286947/number-of-zero-digits-in-factorials – lab bhattacharjee Jan 11 '16 at 04:44
-
@user236182 yes you're right!(I forgot to divide by 125), but then shouldn't all 500 of the last numbers of 2015!-1 be 9's? – Nikunj Jan 11 '16 at 14:22
-
@Nikunj There are exactly $502$ nines at the end of $2015!-1$. – user236182 Jan 11 '16 at 15:39
-
@user236182 yes, but the problem asks only about the last 500 digits – Nikunj Jan 11 '16 at 15:47
3 Answers
There are 403 numbers between 1 and 2015 are divisible by 5. Not all of them contribute just one factor of 5.
The multiples of 25 contribute two factors of 5 (there are 80 such). We already have 483 factors of 5.
A further 16 numbers are divisible by 125 and they contribute yet another factor of 5. We're now up to 499 factors of 5.
Finally, the multiples of 625 contribute yet another factor, and there are 3 such numbers. So we have at least 502 factors of 5 in 2015!. (There are in fact exactly 502 factors, but that's not important here).
There is no dearth of factors of 2, which occur more often than the factors of 5. So we know that $10^{502}$ divides 2015!. I think you know what to do from here!

- 1,173
-
-
3
-
@user236182, Yes, that is true, but I have not verified that above. Of course, the next power of 5 is larger than 2015, but we don't really care about that in this context. You're right, maybe I should mention this. – Snow Jan 10 '16 at 23:33
As pointed out by user236182, Legendre's Formula, proven in $(3)$ of this answer, says that for any prime $p$, the number of factors of $p$ in $n!$ is $$ \frac{n-\sigma_p(n)}{p-1} $$ where $\sigma_p(n)$ is the sum of the digits in the base-$p$ representation of $n$.
Since $2015_{\text{ten}}=31030_{\text{five}}$, the sum of the base $5$ digits is $7$ so the number of powers of $5$ in $2015!$ is $$ \frac{2015-7}{5-1}=502 $$ There are more factors of $2$ so there are $502$ trailing zeroes for $2015!$. Therefore, the last $500$ digits of $2015!-1$ are all nines.
The following formula denotes the number of times that a prime factor $p$ appears in $n!$:
$$C_{n}(p)=\sum\limits_{k=1}^{\infty}\left\lfloor\frac{n}{p^k}\right\rfloor$$
Since $\lfloor\log_{\color\green{2}}2015\rfloor=\color\red{10}$:
$$C_{2015}(\color\green{2})=\sum\limits_{k=1}^{\color\red{10}}\left\lfloor\frac{2015}{\color\green{2}^k}\right\rfloor=2005$$
Since $\lfloor\log_{\color\green{5}}2015\rfloor=\color\red{4}$:
$$C_{2015}(\color\green{5})=\sum\limits_{k=1}^{\color\red{4}}\left\lfloor\frac{2015}{\color\green{5}^k}\right\rfloor=502$$
Let $Z_{n}$ denote the number of trailing zeros in the decimal representation of $n!$:
$$Z_{n}=\min\{C_{n}(2),C_{n}(5)\}$$
So $Z_{2015}=\min\{2005,502\}=502$, and therefore $2015!$ ends with $502$ zeros.
Since $2015!$ ends with $502$ zeros, the last $502$ digits of $2015!-1$ are all nines.

- 43,109