Find the last 5 digits of $$1!+2\cdot2!+3\cdot3!+\cdots+23\cdot23!+24\cdot24!$$

I have no idea how to find an elegant solution to this since the "last 5 digits" part makes it much harder. Usually the number of fives in each factorial reduces the computation here, but here it doesn't work.

  • 13
    $\begingroup$ That sum is $25!-1$ $\endgroup$ – J. W. Tanner Dec 3 '19 at 0:36


$n\times n!=(n+1)!-n!$, so the sum telescopes to $25!-1$.

$25!$ has $6$ factors of $5$ and more than that many of $2$.

  • $\begingroup$ If you don't spot this identity, answering this question would require you to evaluate all 25 terms to get the remainder modulo 10^5, right? Which is really painful. $\endgroup$ – smci Dec 3 '19 at 9:26
  • $\begingroup$ You mean $24$? Still, that would be painful $\endgroup$ – J. W. Tanner Dec 3 '19 at 9:35
  • $\begingroup$ Yes, I meant 24. Which is really painful. My question is: if you don't spot the identity at first sight, you're not going to somehow discover it, and the question is essentially unsolvable by hand. $\endgroup$ – smci Dec 3 '19 at 9:44
  • $\begingroup$ @smci: If I didn't immediately spot the above identity I'd be looking for a pattern. So I'd work out the sum of the first two terms (5), then the first three (23), then the first four (119). Given I've been looking at factorials while doing these sums I would hopefully notice that each of these numbers was one less than a factorial and thus pattern spotted I could get the answer. Depending on the context I might then try to work out why and probably get to this answer but if all that is wanted is the answer then you are done. $\endgroup$ – Chris Dec 3 '19 at 10:05
  • 1
    $\begingroup$ I will agree though that these questions are often about spotting a trick to make the answer simple to work out. In this case I think there are at least two routes to finding that trick (the OP's and mine) and there may be others. You are absolutely right though that if you don't spot the shortcut then you are left working it out by hand which would be a nightmare. But hopefully the fact it is such a nightmare would make you realise that there must be a trick and look harder for it. $\endgroup$ – Chris Dec 3 '19 at 10:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.