Square Pyramidal Number Calculator
Add the squares from one to n to count spheres in a square pyramid, with the previous total shown.
What it does
A square pyramidal number counts spheres stacked in a pyramid with a square base. The bottom layer has n squared spheres, the next has n minus one squared, and so on up to a single sphere at the top. Adding those layers gives the sum of the squares from one to n.
The sequence begins 0, 1, 5, 14, 30 and 55. It is one of the oldest known figurate families, with a closed form that was discussed by ancient mathematicians and remains a standard example of a sum of powers.
The formula is n times n plus one times two n plus one, divided by six. The numerator is always divisible by six, and the tool checks that before returning a result.
This page evaluates the formula with exact integer arithmetic and shows the previous total and ratio beside it. It does not draw the stack, only reports how many spheres it would need.
The layer limit is one hundred thousand, giving a value with about sixteen digits printed in full.
How to use
- Enter the number of layers n from 0 to 100,000.
- Read the square pyramidal number in the main result box.
- Check the previous total and growth beside it.
- The default n = 10 reproduces the worked example.
- Try n = 5 to confirm the value 55.
- Verify a small case by adding squares by hand.
Formula
- n
- The number of layers in the pyramid.
- P(n)
- The total number of spheres.
The formula is the standard closed form for the sum of the first n squares. The numerator is the product of three consecutive style factors and is always divisible by six. The value at n = 0 is zero and at n = 1 is one.
Worked example
Example: ten layers
The page opens with n = 10.
- Write the formula: P(10) = 10 x 11 x 21 / 6.
- Multiply ten by eleven: 110.
- Multiply by twenty one: 110 x 21 = 2310.
- Divide by six: 2310 / 6 = 385.
- The tool reports 385, previous total 285, and growth 1.35x.
- Check by adding squares: 1 + 4 + 9 + ... + 100 = 385.
Reference table
| n | P(n) | Previous | Growth |
|---|---|---|---|
| 0 | 0 | n/a | n/a |
| 1 | 1 | 0 | n/a |
| 2 | 5 | 1 | 5.00x |
| 4 | 30 | 14 | 2.14x |
| 5 | 55 | 30 | 1.83x |
| 10 | 385 | 285 | 1.35x |
Limits
- Layer counts above 100,000 are rejected to keep the output readable.
- The growth column is rounded to two decimals.
- The tool counts spheres but does not draw the pyramid.
- Only the standard square based stack is covered.
Common mistakes
- Using n squared as the total instead of the sum of squares.
- Forgetting to divide by six.
- Using two n plus two instead of two n plus one.
- Expecting cubic growth from a formula that is cubic in n but starts from squares.
- Rounding the division instead of checking exactness.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is the total for ten layers?
P(10) = 10 x 11 x 21 / 6 = 385.
What is the total for five layers?
P(5) = 5 x 6 x 11 / 6 = 55.
What is the total for two layers?
P(2) = 1 + 4 = 5.
Questions
What does this count?
The spheres in a pyramid with square layers of decreasing size.
Is there a simple formula?
Yes, n times n plus one times two n plus one, all over six.
Is the division always exact?
Yes, the numerator is always divisible by six, and the tool verifies it.
How fast does it grow?
The formula is cubic in n, so it grows faster than the square numbers.
Are values exact?
Yes. Arbitrary precision integer arithmetic is used.
What layer count is allowed?
Zero through 100,000.