$\sum_{n=1}^{2017}\left(\left((n+2)^4\bmod{(n+1)^4}\right)\bmod{4}\right)$

What's

$$\sum_{n=1}^{2017}\left(\left((n+2)^4\bmod{(n+1)^4}\right)\bmod{4}\right)$$

What have I tried?

$$(n+2)^4=n^4+8n^3+24n^2+32n+16$$

$$(n+1)^4=n^4+4n^3+6n^2+4n+1$$

Remainder:

$$4n^3+18n^2+28n+15$$

mod:

$$2n^2-1\pmod{4}$$

I can compute $$\sum x^2$$ but I don't know what to do with $$\sum_{n=1}^{2017}\left(2n^2-1\mod{4}\right)$$

• Note that $(n+2)^4\bmod (n+1)^4$ is not the same as $(n+2)^4-(n+1)^4$ when $n\le 3$, so you need to treat those cases specially. Sep 9, 2017 at 17:24
• @MathLover: For $n=2$ I get $$((n+2)^4\bmod (n+1)^4)\bmod 4 = (256\bmod 81)\bmod 4 = 13 \bmod 4 = 1$$ but $$(((n+2)^2-(n+1)^4) \bmod 4)\bmod (n+1)^4 = (175\bmod 4)\bmod 81 = 3\bmod 81 = 3$$ (It goes wrong for $n=4$ too; I had an arithmetic error above). Sep 9, 2017 at 17:37
• @HenningMakholm Thanks for the clarification. Sep 9, 2017 at 17:44

Hint: Compute the sum of even and odd $n$ separately. That is, $$\sum_{n=1}^{2b+1}{(2n^2-1\mod{4})} = \sum_{k=1}^{b}{(2(2k)^2-1\mod{4})} + \sum_{k=0}^{b}{(2(2k+1)^2-1\mod{4})}$$

Just a word of caution: If $a \mod{4} \in \{0,1,2,3\}$ then it is useful to use $2n^2+3$ instead of $2n^2-1$, especially when $n$ is even.

Here $$\{\}\text{ is the fractional part function}$$ So we can write, (if you have problem with this part please comment) $$\text{a mod b}= \{\frac{a}{b}\} b$$

$$\sum_{n=1}^{2017} \{\frac{2 n^2-1}{4}\} 4$$

$$\sum_{n=1}^{2017} \{\frac{ n^2}{2}-\frac{1}{4}\} 4$$

$$\{\frac{ n^2}{2}-\frac{1}{4}\}= \frac {1}{4} \text { for } n\in odd$$ $$=\frac{3}{4} \text{ for }n \in even$$

$$\sum_{n=1}^{1009} \frac{1}{4}4 +\sum_{n=1}^{1008} \frac{3}{4} 4$$

$$\sum_{n=1}^{1009} 1 +\sum_{n=1}^{1008} 3$$ $$1009 + 3 × 1008$$

$$4033$$

What a mess.

First of I must point out that the is meaningless garbage.

$a \mod b + c \mod d$ is an abuse of notation. The statement $a \mod b$ is not a number. It is a class of equivalent numbers. It may but add moduloly to other classes in the same modulo residue system but not to classes in others.

However I will take this (under objection) as an abuse of notation for the remainder function where, for example $28 \mod 5 = 3$ and not $-2$ or $7$ as we are taking one value between $0$ and $5$. This is wrong and you should use a different notation for the remainder function that returns a number.

======

But note: $(k+1)^4 \mod k^4 \equiv 4k^3 + 6k^2 + 4k + 1 \mod k^4$

So $(n+2)^4 \mod (n+1)^4 \equiv 4(n+1)^3 + 6(n+1)^2 + 4(n+1) + 1 \mod (n+1)^4$

And modulo $4$ we get:

$[ (n+2)^4 \mod (n+1)^4] \mod 4 \equiv [2(n+1)^2 + 1]\mod 4 \equiv 2n^2 + 4n + 3\equiv 2n^2 + 3 \mod 4$.

If $n \equiv 0,1,2,3 \mod 4$ we have $2n^2 + 3 \equiv 3,1,3,1 \mod 4$.

So $\sum\limits_{i= 2k+1}^{2k+2} ([ (n+2)^4 \mod (n+1)^4] \mod 4) = 1+ 3 = 4$.

So $\sum\limits_{i= 1}^{2017} ([ (n+2)^4 \mod (n+1)^4] \mod 4)=\sum\limits_{i=1}^{2017}[3\text{ if i is odd}|1\text{ if i is even}]= \frac {2016}2*4 + 3 = 4035$.

For odd $n$, $(n+1)^4$ is a multiple of $4$, so in that case $$(X\bmod(n+1)^4)\bmod 4 = X \bmod 4$$ and we just have to sum $(n+2)^4\bmod 4$. But $(n+2)^4$ is an odd square, and all odd squares are $1$ modulo $4$.

For even $n$ your calculation of $(n+2)^2 \bmod (n+1)^4 = 4n^3+18n^2+28n+15$ works as long as $(n+1)^4 < 2(n+1)^4$ which happens when $n>\frac{1}{\sqrt[4]2-1}-1 \approx 4.3$. So the cases $n=2,4$ need to be treated as special cases.

Otherwise you're summing (as you say) $2n^2-1$ modulo $4$. But since $n$ is now even, $2n^2$ will be a multiple of $4$, so it disappears and only the $-1$ is left.

So for $n\ge 4$ the $+1$ from an odd $n$ cancels out the $-1$ from the even $n$ next to it, and all that is left is $$\sum_{n=1}^{3}\left(\left((n+2)^4\bmod{(n+1)^4}\right)\bmod{4}\right)$$ which can be done by hand easily.

For this term: $\left((n+2)^4\bmod{(n+1)^4}\right)$, it's easy to see that for $n\ge 5$, this is just $\left((n+2)^4-{(n+1)^4}\right)$, since $\frac{7^4}{6^4}<2$. So after the first four terms we can just use the pattern of values $\bmod 4$ to complete the calculation, since for $k$ odd, $k^4\equiv 1 \bmod 4$ and for $k$ even, $k^4\equiv 0 \bmod 4$.

So for odd $n\ge 5$, we add $1-0\equiv 1$ to the sum and for even $n$ we add $0-1\equiv 3$ to the sum, giving us $1007\cdot 1 + 1006 \cdot 3 = 4025$.

Then in the first four terms, the odd terms are unaffected -- $1-0\cdot k \equiv 1$ no matter what $k$ is -- and the two even terms $n = 2,4$ contribute $1$ and $2$ to the sum respectively (from $k=3,2$ in $0-1\cdot k$) , giving a total of $4030$ for the whole sum.