# What number am I ? (square number and triangle number)

I'm a square number,
I'm also a triangle number,
You can write me as the sum of 2 square numbers,
You also can write me as the sum of 2 triangle numbers,
You also can write me as the sum of 1 square number and 1 triangle number,
I'm the smallest number of my kind.

What number am I ?

Bonus Puzzle : Find the second smallest number.

You are

$1225$.

This is a square triangular number, i.e. both a square number and a triangular number. It is also a sum of two squares, since

$1225=5^27^2$ contains every $(4k+3)$-type prime factor an even number of times. (Explicitly, $1225=21^2+28^2$.)

And a sum of two triangular numbers, since

$8\times1225+2=9802=2.13^2.29$ contains every $(4k+3)$-type prime factor an even number of times - see this Maths.SE post. (Explicitly, $1225=T_{19}+T_{45}$.)

And a sum of one square number and one triangular number:

$1225 = 136+1089=T_{16}+33^2$.

It's the smallest square triangular number which is a sum of two squares, since $36$ isn't a sum of two squares.

Bonus round: the second smallest example is probably

$41616$. This is the next smallest square triangular number; it's also a sum of two squares, since it's $2^43^217^2$; it's a sum of two triangular numbers since $8*41616+2=2.5.13^2.197$; I haven't verified whether it's the sum of a square number and a triangular number.

• Being congruent to $1$ mod $4$ is not enough for a number to be the sum of two squares. For example $3 \times 7 = 21$ is not the sum of two squares. A number is the sum of two squares iff in its prime factorisation every prime that is $3$ mod $4$ occurs an even number of times. – Jaap Scherphuis Sep 9 '16 at 7:19
• @JaapScherphuis Oops! For some reason I thought the two were equivalent; I should have known better. That's what I get for answering questions at 4am :-) – Rand al'Thor Sep 9 '16 at 9:27
• @JaapScherphuis - That is only true if one defines a sum of two squares to include the case when one of the squares is $0$, giving for example $9$ as the sum of two squares because $9=3^2+0^2$. – h34 Sep 10 '16 at 19:46
• The fourth condition in the question is unnecessary, since all squares greater than 1 are the sum of two consecutive triangular numbers. – h34 Sep 10 '16 at 20:17

The answer to the bonus question is that the second smallest number that meets the conditions is

1413721.

The

square triangular numbers run 1, 36, 1225, 41616, 1413721, ...

and whereas

41616 is not the answer, because it is not the sum of a square and a triangle number,

the

$1413721 = 1160^2 + 261^2$ (sum of squares)
= $1180^2 + T_{206}$ (sum of a square and a triangle number), where $T_{206}$ is the 206th triangle number, $\frac{(206)(207)}{2}=21321$.