TITLE: what is the remainder when $1!+2!+3!+4!+\cdots+45!$ is divided by 47?
QUESTION [19 upvotes]: Can any one please tell the approach or solve the question 

what is the remainder when $1!+2!+3!+4!+\cdots+45!$ is divided by $47$?

I can solve remainder of $45!$ divided by $47$ using Wilson's theorem but I don't know what must be the approach for this model problems, as $47$ is a prime number I cannot convert it into another factorial and divide.
If any one of you viewing have any idea regarding the approach, please post your approach here.
Thanks in advance.
Regards,
Pavan Kumar

REPLY [4 votes]: If you write the sum backwards you get
$45! + 44! + 43! + ... + 1! = (((···(45+1)44+1)43+1)···+1)2+1$
This creates the sequence
$t_0 = 45, \quad t_{n+1} = (t_n+1)(t_0-n)$
where we wish to find the value of $t_{44}$
This will take $44$ multiplications and $88$ additions, which seems pretty efficient.
Doing the arithmetic modulo $47$, I got $t_{44} \equiv 18 \pmod{47}$.
 n  t[n]     n  t[n]     n  t[n]     n  t[n]     n  t[n]
 0    45     9    44    18    38    27    46    36    18
 1     3    10    24    19    27    28     0    37    11
 2    31    11     4    20    42    29    16    38    37
 3    28    12    24    21    45    30    20    39    40
 4    14    13     1    22    24    31    12    40    17
 5    36    14    15    23    33    32    28    41    25
 6    33    15    10    24     9    33    19    42    31
 7    23    16    37    25    12    34    32    43    17
 8    42    17    30    26    12    35     1    44    18