Math Puzzle

Here’s a puzzle I came up with this morning (though I’m sure others had thought of it before).

We know that the sum of integers from 1 to n — let’s call it S1(n) — is n × (n+1) / 2.

We know that the sum of the squares of integers from 1 to n — let’s call it S2(n) — is n × (n+1) × (2n+1) / 6.

We know that the sum of the cubes of integers from 1 to n — let’s call it S3(n) — is the square of S1(n).

Of course the sum of the cubes (S3) is always divisible by the sum of the integers themselves (S1).

The sum of the squares (S2) is sometimes divisible by the sum of the integers (S1). For instance, consider n=4: 1+4+9+16 = 30, and 1+2+3+4 = 10.

When is the sum of the cubes (S3) ever divisible by the sum of the squares (S2), for n > 1?