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.

  • $\begingroup$ 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}$. $\endgroup$
    – Joffan
    Commented Jan 28, 2015 at 18:33
  • $\begingroup$ 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. $\endgroup$ Commented Jan 28, 2015 at 20:20
  • $\begingroup$ 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. $\endgroup$ Commented Jan 28, 2015 at 20:24
  • $\begingroup$ 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)). $\endgroup$
    – Joffan
    Commented Jan 28, 2015 at 20:31
  • $\begingroup$ 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. $\endgroup$ Commented Jan 28, 2015 at 20:47

4 Answers 4


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$.

  • $\begingroup$ I always think OEIS is a little bit like a magic wand ... :-) $\endgroup$
    – Joffan
    Commented Jan 29, 2015 at 0:41

For the equation:


You can write the solution as:





Or different.





$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.


What about this equation:


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


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.



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



Or different formula.




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .