Centered Square Number Calculator

Number Theory

Centered square number C(n)181
Larger square n^2100
Smaller square (n-1)^281
Previous centered square145
How this was calculated
  1. A centered square number counts the dots in a square array built from two squares, one with side n and one with side n - 1, overlapping around a shared center.
  2. n^2 = 10^2 = 100.
  3. (n - 1)^2 = 9^2 = 81.
  4. C(n) = 100 + 81 = 181. The closed form 2n^2 - 2n + 1 gives the same value: 2 x 100 - 20 + 1 = 181.

Draw a square of dots with n dots on a side. Now draw the slightly smaller square, n-1 on a side, rotated onto the same center. Count every dot in the combined figure and you have a centered square number: C(n) = n^2 + (n-1)^2. The sequence runs 1, 5, 13, 25, 41, 61, 85, 113 - figurate numbers with an unusually practical alter ego, since the same counts give the number of lattice points within taxicab (Manhattan) distance of a center.

This calculator evaluates C(n) for n up to 100,000, shows the two square layers separately, and cross-checks the sum against the closed form 2n^2 - 2n + 1, so every result arrives with its own verification.

The 10th term makes a clean example: 10 squared is 100, 9 squared is 81, and C(10) = 181.

Worked examples

n = 10

(10)

Centered square number C(n)181
Larger square n^2100
Smaller square (n-1)^281
Previous centered square145

n = 5

(5)

Centered square number C(n)41
Larger square n^225
Smaller square (n-1)^216
Previous centered square25

n = 25

(25)

Centered square number C(n)1,201
Larger square n^2625
Smaller square (n-1)^2576
Previous centered square1,105

Two squares, one center

The picture explains the formula. The n-by-n square contributes its full grid; the (n-1)-by-(n-1) square, centered on the same point, contributes a second grid offset by half a step, filling the gaps of the first. Together they form the diamond-flavoured square array that gives the sequence its name.

Counting layer by layer is equally revealing: each new shell around the center adds exactly 4(n-1) dots. The differences of the sequence - 4, 8, 12, 16, 20 - are the multiples of 4, which is why centered square numbers grow quadratically but with a distinctive even rhythm.

Deriving the closed form

Expand the definition: n^2 + (n-1)^2 = n^2 + n^2 - 2n + 1 = 2n^2 - 2n + 1. Two formulas, one sequence - and the calculator evaluates both and compares them on every call, a small built-in audit trail.

The closed form exposes a curiosity: C(n) = 2n(n-1) + 1 is one more than a pronic-like product doubled, so every centered square number is odd - obvious from the picture (a central dot plus symmetric pairs) and immediate from the algebra.

Worked values

C(5) = 25 + 16 = 41. C(10) = 100 + 81 = 181. C(25) = 625 + 576 = 1,201. The layer split is worth watching: the two squares are always close in size, differing by 2n - 1, so the total is always just under twice the larger square.

The previous-term output is handy for the layer interpretation: the jump from C(9) = 145 to C(10) = 181 is 36 = 4 x 9, the shell size the formula promises.

Where centered squares appear

In lattice geometry, C(n) counts the integer lattice points whose Manhattan (taxicab) distance from the origin is at most n - 1 - the diamond-shaped ball of points, whose shell at distance exactly r holds 4r points. That makes the sequence a standard example in the combinatorics of lattice balls, with analogues in every dimension.

Centered polygonal numbers generalize the idea - triangles, pentagons, hexagons each have their centered family - and the square case is the cleanest of them, the only one whose formula is a sum of two consecutive squares. That sum-of-squares form also links C(n) to representations of integers by the form x^2 + y^2, a classical topic with prime-factorization rules of its own.

Checking representations

Run the formula backwards and a question appears: given a number, is it centered square? Solve 2n^2 - 2n + 1 = m by the quadratic formula and test whether n comes out a positive integer - or equivalently test whether 2m - 1 is a perfect square with the right parity. 41 passes: 2 x 41 - 1 = 81 = 9 squared, recovering n = 5.

Numbers that are simultaneously centered square and square are vanishingly rare - the equation becomes a Pell-type problem - which makes a pleasant contrast with the triangular-square family.

The wider figurate zoo

Centered square numbers sit in a taxonomy worth exploring: plain square numbers n^2, centered triangular numbers, the centered hexagonal numbers that count honeycomb shells, and the three-dimensional centered cubes. Each family pairs a picture, a quadratic (or cubic) formula and a shell-counting interpretation.

The sequence here is A001844 in the OEIS, where its many disguises - from sums of two consecutive squares to counts of lattice points - are catalogued with references.

Taxicab balls and diamond shells

Count the integer lattice points within Manhattan distance r of a center point - the points a taxi on a grid can reach in r blocks. The total is the centered square number C(r + 1): 1 point at distance 0, then shells of 4, 8, 12, 16 points at distances 1, 2, 3, 4, accumulating to 5, 13, 25, 41.

That interpretation gives the layer formula a physical meaning: the shell at distance exactly r contains 4r points, the diamond's perimeter - precisely the increments the sequence displays, and the reason the same numbers count cells in grid-based games, cellular automata neighbourhoods and city-block service areas.

Sums of two consecutive squares

Every centered square number is a sum of two consecutive squares by construction, and the converse is immediate, so the sequence is exactly the set of such sums. Asking which primes appear leads somewhere classical: an odd prime is a sum of two squares exactly when it is 1 modulo 4, and consecutive-square sums impose their own further pattern on top.

The number 41 from the examples is a friendly case: 16 + 25, prime, and 1 modulo 4 as the theorem requires. Composite members wear their membership openly too: 85 = 36 + 49, the consecutive squares 6^2 + 7^2, which is C(7).

From dots to formulas

Figurate numbers were Greek mathematics' bridge between geometry and arithmetic, and the centered families show why the bridge mattered: a picture suggests the formula, the formula suggests the induction, and the induction proves what the picture only hinted. The centered square's shell count - each layer a multiple of 4 - is the kind of pattern a student can conjecture from three drawings and prove in four lines.

That pedagogical durability is a feature, not a fallback: sequences like this one are where the habit of exact counting is formed.

Centered squares as sums in disguise

Because C(n) = 2n^2 - 2n + 1, the sequence also counts expressions like the sum of the first n odd numbers arranged in a particular symmetry - and it gives the total number of cells in the first n shells of the diamond ball plus its center, the discrete analogue of area growth in the taxicab metric.

Comparing growth across metrics is instructive: Euclidean discs grow like pi r squared, taxicab diamonds like 2 r squared - the constant 2 in the closed form is the taxicab world's pi, a small fact that delights students of metric geometry.

Testing membership quickly

To test whether m is a centered square number, compute 2m - 1 and check for a perfect square whose root is odd: m = 181 gives 361 = 19 squared, and n = (19 + 1) / 2 = 10 falls out. The test is the quadratic formula wearing work clothes, and it is exact in integer arithmetic at any size this page handles.

That invertibility - formula forward, square test backward - is what makes figurate families satisfying calculator subjects: generation and recognition are equally cheap.

Centered squares in crystal and game grids

Diamond-shaped neighbourhoods appear wherever movement costs are counted in steps: the movement range of a unit in grid tactics games, the growth front of a crystal depositing atom by atom in the Manhattan metric, the service diamond of a courier who travels in blocks. Each is counted by a centered square number.

The formula's two-square decomposition even mirrors the geometry: the diamond of radius n - 1 splits into two overlapping square grids, one axis-aligned and one rotated - which is the original figurate picture that named the sequence.

FAQs

What is a centered square number?

The count C(n) = n^2 + (n-1)^2 of dots in a centered square arrangement: two overlapping squares of sides n and n-1 sharing a center.

What is the 10th centered square number?

C(10) = 100 + 81 = 181.

What is the formula for C(n)?

C(n) = n^2 + (n-1)^2, which simplifies to 2n^2 - 2n + 1.

What are the first centered square numbers?

1, 5, 13, 25, 41, 61, 85, 113.

How many dots does each new layer add?

Layer n adds 4(n-1) dots over the previous term, so the sequence grows by 4, 8, 12, 16 and so on.

Is 41 a centered square number?

Yes - C(5) = 25 + 16 = 41.

Are centered square numbers always odd?

Yes - the closed form 2n^2 - 2n + 1 is one more than an even number, matching the central dot plus symmetric pairs in the picture.

How many lattice points lie within Manhattan distance 2 of a center?

13: the center itself, 4 points at distance 1 and 8 points at distance 2 - the centered square number C(3) = 9 + 4 = 13.

Is 221 a centered square number?

Yes - 221 = 121 + 100 = 11^2 + 10^2, so it is C(11), the term right after C(10) = 181. The quick test agrees: 2 x 221 - 1 = 441 = 21^2, and n = (21 + 1) / 2 = 11.

Sources

Related calculators

Cosine Similarity Calculator
Cosine similarity and the angle between two vectors of 2 to 5 dimensions, from the dot product and the vector lengths.
Lognormal Distribution Calculator
Compute the CDF, PDF, mean and median of a lognormal distribution from its log-scale mu and sigma.
Sphere Volume Calculator
Volume and surface area of a sphere from its radius — plus diameter, great-circle circumference and the hemisphere figure.