27

It's been two years or so since I've finished my math undergrad (and I'm doing something non-math related now, unfortunately), so I apologize if what is to follow isn't a very good question!

Prove that for all Integers $n$, $n(n + 1)(2n + 1)$ will always be divisible by 6.

I can do that using induction, but I wanted to try a different way. Does it work to use modular arithmetic in the following way?

Let $f(n) = n(n+1)(2n+1) = 2n^3 + 3n^2 + n$. All we need to show is that $f(n)$ is divisible by both $2$ and $3$ for any choice of $n$.

Evaluate mod $2$.

$f(n) = n(n+1)(2n+1) = n(n+1)(0 + 1)$ mod $2 = n(n+1)$ mod $2$. Two consecutive numbers; one of them must be even, and so $f(n)$ is divisible by $2$.

Evaluate mod $3$

There are three possible residues for n modulo $3$: $0, 1,$ or $2$.

If the residue is $0$, then $f(n)$ is divisible by $3$.

If the residue is $1$, then $f(n) = n(n+1)(2n+1) = 1(1+1)(2*1+1) = 1(2)(3) = 0$ mod $3$.

If the residue is $2$, then $f(n) = 2(2+1)(2*2+1) = 2(3)(2) = 0$ mod $3$.

In any case, $f(n)$ is divisible by $3$.

Since $f(n)$ is divisible by $2$ and by $3$, it is divisible by $6$. The result follows.

Thank you!

August
  • 1,562
  • 8
    Yes, your logic is correct. Modular arithmetic works fine for a problem like this – QC_QAOA Feb 27 '18 at 07:42
  • 5
    That works, or just use that $;n(n+1)(2n+1) \color{blue}{- 2(n-1)n(n+1)} = \color{red}{3 n (n + 1)};$ where both colored terms are multiples of $6$ for obvious reasons. – dxiv Feb 27 '18 at 07:46
  • My only complaint is "If the residue is 1" could mean $n\equiv1\bmod3$ or $f(n)\equiv1\bmod3$. And you might as well replace "$f(n)$ is divisible by 3" with a calculation similar to the next two. – Teepeemm Feb 27 '18 at 15:11
  • 4
    It's perfectly correct and in my opinion better and even arguably more fundamental than induction. – fleablood Feb 27 '18 at 17:34
  • 1
    It becomes even easier if you say there are three possible modulo classes: 0, 1, -1. If $n\equiv 0 \mod 3$ then $n\equiv 0\mod 3$, if $n\equiv -1 \mod 3$ then $n+1 \equiv 0 \mod n$. It doesn't help that much here but it would for trying to prove something like $n^7(2n^{36}+1)$ is divisible by $3$. If $n\equiv 2\mod 3$ then $2n^{36} +1 \equiv 2^{37} + 1$ is hard to do but $n\equiv -1\mod 3$ then $2n^{36} + 1\equiv 2(-1)^{36}+1\equiv 21+1 \equiv 3\equiv 0 \mod 2$ is easy. – fleablood Feb 27 '18 at 17:44
  • You could say one of $2n$, $2n+1$, $2n+2$ is divisible by $3$ (three consecutive integers), and since $2$ and $3$ are coprime you have one of $n$, $2n+1$, $n+1$ is divisible by $3$ – Henry Feb 28 '18 at 08:37

4 Answers4

20

It's correct, but you can go further.

Fermat’s little theorem

If $p$ is a prime number, then, for every integer $n$, $$n^p\equiv n \pmod{p}$$

There are several proofs. A simple one considers the fact that, if $n$ is coprime with $p$, then $n,2n,3n,\dots,(p-1)n$ are all distinct modulo $p$ and not congruent to $0$, so $$ 1\cdot2\cdot\dots\cdot(p-1)\equiv n\cdot2n\cdot\dots\cdot(p-1)n\pmod{p} $$ which implies $n^{p-1}\equiv1\pmod{p}$. Therefore $n^p\equiv n$, which also holds when $n\equiv0\pmod{p}$.

Modulo $2$

$n(n+1)(2n+1)\equiv n(n+1)\equiv n^2+n\equiv n+n\equiv0\pmod{2}$ because $n^2\equiv n\pmod{2}$ (little Fermat).

Modulo $3$

$n(n+1)(2n+1)\equiv2n^3+3n^2+n\equiv2n^3+n\equiv2n+n\equiv0\pmod{3}$ because $n^3\equiv n\pmod{3}$ (little Fermat).

egreg
  • 238,574
20

This is a perfectly good argument. In my opinion, solving divisibility problems via modular arithmetic is often a much cleaner approach than using divisibility directly, and this is one such situation.

As an aside, you could convert your mod-3 argument into a "product of three consecutive numbers":

$$ n(n+1)(2n+1) \equiv 2 n(n+1)(n + \frac{1}{2}) \equiv 2 n(n+1)(n+2) \pmod{3} $$

  • Ah! Thanks, Hurkyl! I think I did get to a point where I had three consecutive numbers mod 3, as a product of something like n(n-1)(n-2). It slipped my mind to convert it into n(n+1)(n+2).

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

    As a side, though. I don't remember using fractions in modulo arithmetic. I do realize what you're doing with the inverses going on. Is the way you wrote it (using fractions) acceptable to use or is that just for typing convenience?

    – August Feb 27 '18 at 08:18
  • 4
    That last inference is invalid because it relies on $n+\frac{1}2=n+2 \mod 3$. – Rosie F Feb 27 '18 at 10:12
  • 6
    Or notice that $n(n+1)(2n+1) = n(n+1)[n+(n+1)]$. If $n$ and $n+1$ are not divisible by $3$, their sum will be. – Joker_vD Feb 27 '18 at 10:32
  • 1
    @RosieF: I'm not keen on the notation, but the equality that holds modulo $3$ (and is used) is $2 (n+2)=2n+1$. But using $1/2$ is not really wrong since $2$ is invertible, so, $1/2=2$. – Martin Argerami Feb 27 '18 at 12:59
  • 1
    To avoid explaining $1/2$, you may also write it as $n(n+1)(2n+1)\equiv n(n+1)(-n+1)\equiv-(n-1)n(n+1)\pmod 3$. – Emil Jeřábek Feb 27 '18 at 14:52
  • Or $n(n+1)(2n+1)=n(n+1)(2n+4)=2n(n+1)(n+2)\bmod 3$. I felt that the answer deserved criticism because replacing $2n+1$ by $n+\frac{1}2$ fails to lead validly to what is to be proved. – Rosie F Feb 27 '18 at 16:26
  • Joker_vD's point is very neat. – PatrickT Feb 27 '18 at 19:03
  • Integers mod 3 are a field, so you can divide by any nonzero element, and you definitely have $1/2 = 2$ and $2n+1=2(n+1/2)=2(n+2)$. – Meni Rosenfeld Feb 27 '18 at 22:43
  • I like $(2n+1) = (2n+1+3) = 2(n+2) mod 3$. That should be clear to anyone who knows what "mod" means and requires no knowledge about fields. – Sjoerd Feb 28 '18 at 00:35
13

Yes, your reasoning is valid.

If a number is divisible by $2$ and $3$, it is divisible by $6$ and each case can be proven using your method.

Trivia:

$$\sum_{i=1}^n i^2= \frac{n(n+1)(2n+1)}{6}$$

hence,$$n(n+1)(2n+1)= 6 \sum_{i=1}^n i^2$$

Siong Thye Goh
  • 149,520
  • 20
  • 88
  • 149
  • 2
    Technically this might be a circular proof if the reason OP is doing this is to show that the formula for the sum will always produce an integer. – Tyberius Feb 27 '18 at 18:42
  • 1
    @Tyberius: But it is a simple induction to show $\sum_{i=1}^n i^2$ is an integer – Henry Feb 28 '18 at 08:34
2

$$n(n+1)(2n+1)=n(n+1)(2n+4-3)=2\underbrace{n(n+1)(n+2)}-3n(n+1)$$

Use The product of n consecutive integers is divisible by n factorial

  • 1
    Thanks, lab. I was asking about my own proof though. Does mine work? With the residues involved and overall? – August Feb 27 '18 at 07:41