Square Triangular Number Calculator

Find the numbers that are both square and triangular, from a short recurrence that grows very fast.

Math and PercentUpdated 2026-11-182 min read
Square Triangular Number Calculator
A whole number from 0 to 200.
Square triangular number
...
Previous term...
Growth from previous...

What it does

A square triangular number is an integer that is simultaneously a perfect square and a triangular number. After the trivial values zero and one, the next examples are 36, 1225, 41616 and 1413721. Such numbers are rare, which makes them a classic puzzle in number theory.

The problem goes back to ancient mathematics and is closely tied to Pell equations. Finding all solutions reduces to a recurrence rather than a search, because the underlying equation has an infinite but highly structured set of solutions.

The recurrence used here is a(n) equals 34 times a(n minus one), minus a(n minus two), plus two, starting from zero and one. The large coefficient 34 explains why the terms grow so quickly; by index four the value is already 41616.

This page computes a term with exact integer arithmetic and shows the previous value and ratio beside it. The ratio settles near 33.97, the larger root of the characteristic equation.

The index limit is 200. At that point the number has well over three hundred digits, so the printed value is long but still exact.

How to use

  1. Enter an index n from 0 to 200.
  2. Read the square triangular number in the main result box.
  3. Check the previous term and growth beside it.
  4. The default index 4 reproduces the worked example.
  5. Try n = 3 to confirm the value 1225.
  6. Verify a small term by checking that it is both a square and triangular number.

Formula

a(0) = 0, a(1) = 1, and a(n) = 34a(n - 1) - a(n - 2) + 2 for n >= 2
n
The index in the sequence of square triangular numbers.
a(n)
The nth number that is both square and triangular.

The recurrence comes from rewriting the condition that a number is both square and triangular as a Pell equation. The characteristic roots are 17 plus twelve times the square root of two and its conjugate, so the dominant root is about 33.97 and controls the growth of the ratio.

Worked example

Example: index 4

The page opens with n = 4.

  1. Start from a(0) = 0 and a(1) = 1.
  2. Compute a(2) = 34 x 1 - 0 + 2 = 36.
  3. Compute a(3) = 34 x 36 - 1 + 2 = 1225.
  4. Compute a(4) = 34 x 1225 - 36 + 2 = 41616.
  5. The tool reports 41616, previous term 1225, and growth 33.97x.
  6. Check the result: 41616 is 204 squared and also the 288th triangular number.

Reference table

Square triangular numbers
na(n)Square rootTriangular index
0000
1111
23668
312253549
441616204288
5141372111891681

Limits

  • Indices above 200 are rejected because the printed integers become very long.
  • The growth column is rounded to two decimals.
  • The tool computes the sequence value, not the square root or triangular index.
  • Only nonnegative indices are used.

Common mistakes

  • Searching integer squares and triangular numbers by brute force instead of using the recurrence.
  • Dropping the constant plus two in the recurrence.
  • Assuming every triangular number is also a square at large sizes.
  • Starting the recurrence at a(1) = 1 and a(2) = 2 by mistake.
  • Rounding the ratio instead of computing it from exact values.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is a(4)?

a(4) = 34 x 1225 - 36 + 2 = 41616.

What is a(3)?

a(3) = 34 x 36 - 1 + 2 = 1225.

Why is 36 a square triangular number?

36 is 6 squared and also the sum from 1 to 8, the eighth triangular number.

Questions

What is a square triangular number?

An integer that is both a perfect square and a triangular number.

Are there infinitely many?

Yes, and the recurrence generates every one of them.

How is this linked to Pell equations?

The condition that a number is both square and triangular reduces to a Pell equation with infinitely many solutions.

What is the growth ratio?

About 33.97, the dominant root of the recurrence characteristic equation.

Are values exact?

Yes. Arbitrary precision integer arithmetic is used.

What index range is accepted?

Zero through 200.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.