That is, (a + 1)^3 and a^3

Let's consider the difference between the two

(a + 1)^3 - a^3

we get

a^3 + 3a^2 + 3a + 1 - a^3

= 3a^2 + 3a + 1

I'm interested in finding the set of numbers of this difference being a square, that is

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

3a^2 + 3a + 1 = n^2

For example, (8^3) - (7^3) = 169 = 13^2

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

for some integer k.

We need to determine "a" such that 3a^2 + 3a + 1 = n^2

This is given in the OEIS

0, 7, 104, 1455, 20272, 282359, 3932760, 54776287, 762935264, 10626317415, 148005508552, 2061450802319, 28712305723920, 399910829332567, 5570039304932024, 77580639439715775, 1080558912851088832, ...

The recurrence for this sequence is a(n) = 14a(n-1) - a(n-2) + 6.

And,

(104+1)^3 - (104^3) = 32761 = 181^2

(1456^3) - (1455^3) = 6355441 = 2521^2

Giving us the sequence A001570

Numbers n such that n^2 is simultaneously square and centered hexagonal.

A **centered hexagonal number**, or **hex number**, is

Since n^2 = 3a^2 + 3a + 1

then 4n^2 = 12a^2 + 12a + 4

And 4n^2 - 1 = 12a^2 + 12a + 3

4n^2 - 1 = 3(2a + 1)^2

If p is prime and p|(2a + 1)^2,

then p|2n + 1 or p|2n − 1,

but p cannot divide both (2n + 1) and (2n - 1)

Otherwise, p|(2n+1)−(2n−1) = 2, which cannot be since (2a+1)^2 is odd.

We now have two possible cases (u and v are integers):

2n + 1 = u^2 and 2n - 1 = 3v^2,

or 2n + 1 = 3u^3 and 2n - 1 = v^2

The former case implies

2n = u^2 - 1 = 3v^2 + 1 or u^2 = 3v^2 + 2 = 2 (mod 3)

which is impossible since for any integer u, u^2 = 0 or 1 (mod 3)

Therefore,

2n - 1 = v^2 for some odd positive integer v.

Let k = (v - 1)/2.

Then

k^2 + (k + 1)^2 = 2k^2 + 2k + 1 = {(2k + 1)^2 + 1}/2 = (v^2 + 1)/2 = n.