Just 2 years ahead

Find the remainder when 1 ! + 2 ! + 3 ! + 4 ! + + 20 ! 1!+2!+3!+4!+\ldots+20! is divided by 2017 2017 .


The answer is 101.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

David Jedelsky
Feb 13, 2019

Considering n ! = ( n 1 ) ! n n! = (n-1)! n the reminder of each term in summation r k = k ! ( m o d 2017 ) r_k=k! \pmod{2017} can be expressed from previous reminder as r k = r k 1 k ( m o d 2017 ) r_k = r_{k-1} k \pmod{2017} . The result is then k = 1 20 r k ( m o d 2017 ) \displaystyle\sum_{k=1}^{20} r_k \pmod{2017} .

It can be easily evaluated in python 'Coding environment' using first or second code sample:

1
2
3
4
5
6
7
8
9
M=2017
N=20

s,r = 0,1
for k in range(1,N+1):
    r = (r*k)%M
    s += r

print(s % M)

1
2
3
# For one-liners and pure functionalists
from itertools import accumulate
print(sum(accumulate(range(1,20+1),lambda r,k: (r*k)%2017))%2017)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...