prove 2 | n^2 + n + 1

if n is even, n^2+n+1 is odd

if n is odd, n^2 is odd, so n^2+n+1 is odd

I think you meant 2∤n^2+n+1

n^2+n+1 = (n+1)^2 - n

(n+1)^2 and n will always have the different parity, so the difference between them is always odd.

To prove that 2 divides n^2 + n + 1, we need to show that there exists an integer k such that n^2 + n + 1 = 2k.

First, let's consider the possible residues of n modulo 2. Any integer can be either even or odd.

Case 1: n is even.
If n is even, it can be written as n = 2m, where m is an integer. Substituting this into the equation, we get:
n^2 + n + 1 = (2m)^2 + 2m + 1 = 4m^2 + 2m + 1 = 2(2m^2 + m) + 1.
Since 2(2m^2 + m) is an even number, we can let k = (2m^2 + m), which means n^2 + n + 1 = 2k. Thus, the claim holds when n is even.

Case 2: n is odd.
If n is odd, it can be written as n = 2m + 1, where m is an integer. Substituting this into the equation, we get:
n^2 + n + 1 = (2m + 1)^2 + (2m + 1) + 1 = 4m^2 + 4m + 1 + 2m + 1 + 1 = 4m^2 + 6m + 3 = 2(2m^2 + 3m + 1) + 1.
Again, since 2(2m^2 + 3m + 1) is an even number, we can let k = (2m^2 + 3m + 1), which means n^2 + n + 1 = 2k. Thus, the claim holds when n is odd.

In both cases, we have shown that there exists an integer k such that n^2 + n + 1 = 2k, so we can conclude that 2 divides n^2 + n + 1 for any integer n.