Square Pyramidal Number Calculator
Find any square pyramidal number Pₙ.
Result
How it is calculated
The n-th square pyramidal number is Pn = n × (n + 1) × (2n + 1) ÷ 6, which equals the sum 1² + 2² + … + n². Here n is the number of layers of the pyramid, counted from the single ball on top down to the base layer of n × n balls. The input is cut to a whole number, so 3.7 is treated as 3, and it must be between 0 and 100,000. Negative values and values above 100,000 give no result. n = 0 gives 0, an empty pyramid. The answer is an exact whole number, shown with thousands separators, and the formula is used directly rather than adding the squares one by one.
Worked example
A pyramid of 10 layers has a 10 × 10 layer at the bottom, then 9 × 9, and so on up to a single ball at the top. Using the formula: 10 × 11 × 21 = 2,310, and 2,310 ÷ 6 = 385. As a check, add the squares: 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 = 385. So 385 equal spheres are needed to build the pyramid.
Common mistakes
- Confusing it with a square number or with a triangular number. Pn is the running total of squares, so P10 is 385, while 10² is only 100.
- Entering the number of balls in the base layer as the number of balls you have. The input is the number of layers n, not the total; to find the layers for a given stock, try n values until Pn reaches your total.
- Using the formula for a pyramid with a different base. A triangular base gives tetrahedral numbers, and this tool covers only a square base.
- Typing a decimal and expecting interpolation. Layers are whole, so 3.7 is read as 3 and the result is 14, not a value between 14 and 30.
- Starting the count at the wrong layer. The top ball counts as layer 1, so a pyramid of 3 layers has 1 + 4 + 9 = 14 balls and not 4 + 9.
About this calculator
The nth square pyramidal number Pₙ = n(n+1)(2n+1)/6 is the sum of the first n perfect squares (1² + 2² + … + n²), representing the number of spheres that stack into a pyramid with a square base n layers tall — one layer of n² balls, the next of (n−1)², and so on down to a single ball on top.
These numbers are famous in number theory for the cannonball problem: the question of when a square pyramidal stack can be rearranged into a flat square array, which turns out to happen only for n=1 and n=24 (1+4+9+…+24² = 4900 = 70²), a result proved using elliptic curves. Mathematics educators use square pyramidal numbers to teach summation formulas, and puzzle enthusiasts encounter them in classic stacking problems.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Square pyramidal numbers hide a famous curiosity: apart from 1, only P24 = 4,900 is also a perfect square, namely 70 squared, which means 4,900 balls could be stacked as a pyramid and also laid out as a square. You can confirm it by typing 24. The input is cut to a whole number. If you use this for a physical stack, what are you stacking?