# Three different examples of three consecutive triangular numbers whose sum is a perfect square for n > or equal to 20

Three different examples of three consecutive triangular numbers whose sum is a perfect square for n > or equal to 20. (In other words their sum must be greater than or equal to 400 and must be a perfect square).

I can use a program such as maple to write a script for it but I don't know where to even begin.

Using Joffan's suggestion I wrote out

$\frac{1}{2} j(j+1) + \frac{1}{2} k(k+1) + \frac{1}{2} l(l+1) = m^2$

I am just not certain how I can translate this into maple's input language.

• I suggest you write down the formula for three consecutive triangular numbers, and see if that suggests anything. At least it would indicate some thinking on your part, which always encourages response here. The formula for Triangular number $n$ is $\frac{n(n+1)}{2}$. – Joffan Jan 28 '15 at 18:33
• Well I know how i would set that up on paper. It would be the sum from k to k+2 of [K(K+1)]/2 = some other arbitrary variable squared but I have no idea how to translate that into maple as I have never used it much and my teacher just glanced over it and expected us to learn how to use this complex program on our own. I plan on asking about it tomorrow but I wanted to try to gain some insight prior to that. – numtheory1555242 Jan 28 '15 at 20:20
• Also I am currently looking up tutorials on maple but it is a complex program and I don't understand how my teacher just expects us to understand how to input stuff into this program without knowing anything about the required formatting. – numtheory1555242 Jan 28 '15 at 20:24
• Try editing your post to add the three-part calculation - write it all out in terms of k (either the smallest number or the middle number, whichever you prefer (and define)). – Joffan Jan 28 '15 at 20:31
• tried to do it a bit and I know that the first three are 15 21 and 28 cause they equal 64 but that is too small to be a relevant answer. – numtheory1555242 Jan 28 '15 at 20:47

OK you have two different questions... programming in Maple is probably taken elsewhere, but I will say that for most programs, clarity is more important than efficiency. So having separate variables for your triangular numbers and for the square you're aiming at is fine if that makes your program clearer.

For mathematical analysis, though, if two items are related it's best to make that as explicit as possible. So your:

$\frac{1}{2} j(j+1) + \frac{1}{2} k(k+1) + \frac{1}{2} l(l+1) = m^2$

since we're talking about $T_{k-1}+T_{k}+T_{k+1}, \to j=k-1$ and $l=k+1$ we can write as

$\frac{1}{2} (k-1)(k) + \frac{1}{2} k(k+1) + \frac{1}{2} (k+1)(k+2) = m^2$

which could be simplified - or, more directly: \begin{align} T_{k-1}+T_{k}+T_{k+1} &= (T_{k} - k)+T_{k}+(T_{k}+(k+1))\\ &= 3T_k+1\\ &= 3\frac{1}{2}(k^2+k) + 1 \end{align}

which might help - it certainly shows that $m$ cannot be a multiple of 3.

I will expand the solution of @Joffan.

The numbers $k > 0$ such that $k^2$ is a sum of three consecutive triangle numbers (namely $T_{k-1}$, $T_k$, $T_{k+1}$) can be found in the OEIS database. Their generating function is $$\frac{x(1-x)(1+3x+x^2)}{1-10x^2+x^4}.$$

And what may be surprising they satisfy relatively simple recurrence relation: $a_n = 10a_{n-2}-a_{n-4}$, where $a_1 = 1$, $a_2 = 2$, $a_3=8$ and $a_4 = 19$.

• I always think OEIS is a little bit like a magic wand ... :-) – Joffan Jan 29 '15 at 0:41

For the equation:

$$\frac{a(a+1)}{2}+\frac{b(b+1)}{2}+\frac{c(c+1)}{2}=x^2$$

You can write the solution as:

$$a=-p^2+p-\frac{s(s+1)}{2}$$

$$b=-p^2-p-\frac{s(s+1)}{2}$$

$$c=s$$

$$x=p^2+\frac{s(s+1)}{2}$$

Or different.

$$a=-\frac{p(p+3)}{2}-s^2-s-1$$

$$b=-\frac{p(p+3)}{2}-s^2+s-1$$

$$c=-p-2$$

$$x=\frac{p(p+3)}{2}+s^2+1$$

$p,s$ - Integers asked us. Not a lot not in a convenient form the recorded decision, but it is. Go to positive numbers is not difficult.

$$\frac{(k-1)k}{2}+\frac{k(k+1)}{2}+\frac{(k+1)(k+2)}{2}=x^2$$

For this we need to use the solutions of the Pell equation.

$$p^2-6s^2=1$$

To find solutions easily. Knowing the first solution $(p_1;s_2)$ - $(5;2)$

Knowing one solution, the following can be found by the formula.

$$p_2=5p_1+12s_1$$

$$s_2=2p_1+5s_1$$

Knowing any solution and using it, you can find the solution to this equation by the formula.

$$k=p(4s-p)$$

$$x=p^2-3ps+6s^2$$

Or different formula.

$$k=-2p^2-8ps-6s^2$$

$$x=2p^2+9ps+12s^2$$