Sum Of Cubes Calculator
Calculate the sum of cubes for a number range and get the total quickly, useful for patterns, algebra practice, and series work.
Enter the Details
Result will appear here...
What this calculator does
This adds up the cubes of a run of whole numbers. Give it a start and an end, and it works out 13 + 23 + 33 and so on across that range, without you cubing and adding a single thing.
And there is a genuinely lovely piece of mathematics hiding inside it, which the next section is about. It runs right here in the browser.
Using the calculator
- Enter the first number (n1), the start of the range.
- Enter the second number (n2), the end of the range.
- Press Calculate.
It returns the sum of the cubes from n1 to n2. Use whole numbers, with n1 no bigger than n2. Reset clears both boxes.
The beautiful bit: cubes add up to a square
Here is a fact worth pausing on. Add up the cubes of the first few whole numbers and you always land on a perfect square. Not sometimes. Always. And not just any square, but the square of the plain sum of those same numbers:
13 + 23 + 33 + ... + n3 = (1 + 2 + 3 + ... + n)2
Take the first four. Their cubes are 1 + 8 + 27 + 64 = 100. And 100 is exactly 10 squared, where 10 is 1 + 2 + 3 + 4. So the sum of the cubes equals the square of the sum. It feels like it should not be true, and yet it always is. This is known as Nicomachus's theorem.
The formula, and the range version
Since 1 + 2 + ... + n is the nth triangular number, n(n + 1) ÷ 2, the sum of the first n cubes has a tidy closed form:
sum of first n cubes = [ n(n + 1) ÷ 2 ]2
To total the cubes over a range that does not start at 1, the tool uses the natural trick: work out the sum all the way up to n2, then subtract off the sum up to just before n1. In other words, [ n2(n2 + 1) ÷ 2 ]2 minus [ (n1 − 1)n1 ÷ 2 ]2. That leaves exactly the cubes from n1 to n2 and nothing else.
A worked example
Sum the cubes from 1 to 4.
- By adding: 13 + 23 + 33 + 43 = 1 + 8 + 27 + 64 = 100.
- By the formula: [ 4 × 5 ÷ 2 ]2 = 102 = 100. The two agree.
For a range that skips the start, say 2 to 4, take the sum to 4 and remove the sum to 1: 100 − 13 = 100 − 1 = 99, which is 8 + 27 + 64.
Where it comes from
This identity is old. It is credited to Nicomachus of Gerasa, a Greek mathematician writing around 100 CE, who noted the pattern in his book Introduction to Arithmetic. It was found independently centuries later by the Indian mathematician Aryabhata, and it has been proved in dozens of different ways since, several of them purely visual, arranging cubes into a perfect square without a word of algebra. As one writer put it, every student of number theory has surely marvelled at this fact. It is a small piece of mathematics that has kept delighting people for nearly two thousand years.
Questions people ask
What is the formula for the sum of cubes?
The sum of the first n cubes is [ n(n + 1) ÷ 2 ]2, which is the square of the nth triangular number.
Is the sum of cubes always a perfect square?
Yes, when you sum from 1. The sum of the first n cubes is exactly the square of 1 + 2 + ... + n, a result called Nicomachus's theorem.
Why does the sum of cubes equal the square of the sum?
Because both come to the same value, the square of the nth triangular number. It can be shown by algebra or by a neat geometric arrangement of the cubes into a square.
Can I sum cubes over a range, not just from 1?
Yes. The tool totals the cubes up to your end value and subtracts the total up to just before your start value, leaving the range you asked for.
What is Nicomachus's theorem?
The statement that the sum of the first n cubes equals the square of their sum: 1³ + 2³ + ... + n³ = (1 + 2 + ... + n)².
References
A note on where this comes from. That the sum of the first n cubes equals the square of the nth triangular number is a classical result of number theory known as Nicomachus's theorem, after Nicomachus of Gerasa (c. 60 to c. 120 CE), who recorded the underlying pattern in his Introduction to Arithmetic. For further reading, see Squared triangular number.
- Nicomachus of Gerasa, Introduction to Arithmetic (c. 100 CE), the origin of the identity now called Nicomachus's theorem.
- Roger B. Nelsen, Proofs Without Words (1993), which gives several visual proofs that the sum of cubes is the square of the sum.
- The sums are the squared triangular numbers, OEIS sequence A000537. https://oeis.org/A000537
Okan Atalay is a results driven senior operations manager and a graduate of Industrial Engineering from Bilkent University. With over 22 years of experience in textile manufacturing and integrated operations, he has led large scale business process improvements and strategic planning initiatives. Currently, he serves as a top mathematics expert for a global ed tech platform, where he applies his analytical expertise to solve complex mathematical problems. At Eon Tools, he reviews converter and maths tools.