Find the remainder when 1!+2!+...+299!+300! is divided by 21

If you note that we only need to calculate

6
s=∑ i!
n=1

or

s=873 mod 21 = 12

Because all terms 7! and beyond are divisible by 21.

To find the remainder when the sum of factorials from 1! to 300! is divided by 21, we can calculate the remainder for each factorial separately and then find the sum.

Here's how you can calculate the remainder for each factorial:

1. Divide each factorial by 21.
- 1! divided by 21 leaves a remainder of 1.
- 2! divided by 21 leaves a remainder of 2.
- 3! divided by 21 leaves a remainder of 6.
- ...
- 300! divided by 21 will leave a remainder of 0.

The remainders of each factorial will repeat in a pattern since 21 is a factor of all the factorials from 21 and onwards.

Now let's find the sum of these remainders:

To calculate this sum efficiently, we can group the remainders into cycles of length 21. The remainders will repeat after every 21 terms.

In each cycle of 21, the remainders will add up to 0 because the sum of remainders from 1! to 21! is divisible by 21.

Since there are 300 factorials, we have 300/21 = 14 complete cycles. Each complete cycle will contribute 0 to the sum.

This means 14 cycles * 0 = 0 will be added to the sum.

Now, let's consider the remaining 300%21 = 18 terms (terms 1 to 18) that do not complete a full cycle.

The sum of these remaining terms' remainders is: 1 + 2 + 6 + 24 + ... + (18th term)

To simplify this expression, we can first calculate the sum of terms from 1 to 4 because they form a pattern:

1 + 2 + 6 + 24 = 33

We can see that the sum of the first four terms forms a pattern where each term is multiplied by the next factor.

So now, we have:

33 + (5th term) + ... + (18th term)

To find this sum, we need to calculate each term's remainder and then sum them up.

5! divided by 21 leaves a remainder of 24.
6! divided by 21 leaves a remainder of 6.
...
18! divided by 21 leaves a remainder of 0.

The sum of these remainders is 24 + 6 + ... + 0.

Calculating this sum, we get:

24 + 6 + 0 + ... + 0 = 30

Thus, the sum of the remainders of the 300 factorials from 1! to 300! divided by 21 is 0 (from the complete cycles) + 30 (from the remaining terms) = 30.

Therefore, the remainder when 1! + 2! + ... + 299! + 300! is divided by 21 is 30.