How to Quickly Add the Integers From 1 to n?
What does 1 + 2 + 3 + … + n equal? Find How to Quickly Add the Integers From 1 to n out how to impress your friends at parties by quickly calculating the sum of all the integers from 1 up to any number they choose.
Jason Marshall, PhD
Listen
How to Quickly Add the Integers From 1 to n?
In the last episode, we learned an amazing trick that you can use to quickly add up all the integers from 1 to 100. And that really was no small feat since we turned the herculean task of performing 100 addition problems—that is adding up 1 + 2 + 3 + 4 + … + 100—into a cute fuzzy kitten of a single multiplication problem. Although this trick is undeniably impressive, it’s not exactly the kind of thing you can pull out at parties to impress your friends since they could claim that you simply memorized the answer.
Which might lead you to wonder: Instead of just adding up the first 100 positive integers, is there a way to quickly calculate the sum of the first 50, 200, or maybe even 1,000 positive integers? In other words, is there a way to quickly calculate the sum of all the integers from 1 up to any other number—which we’ll call “n”—that your friends might throw at you? That would be a rather impressive trick, right? Well, as luck would have it, there is a way to do it…and that’s exactly what we’re going to talk about today.
Recap: Adding the Integers From 1 to 100
Before we figure out how to add up all the integers from 1 to n, let’s recap how to add up all the integers from 1 to 100. The key to this is our friend the associative property of addition which says that you are free to add together a group of numbers in any order you like. In the past, we’ve seen how this freedom can be used to help you perform lightning fast mental addition, and now this same property comes to the rescue again since it means that we’re free to add up all the numbers from 1 to 100 in pairs.
In particular, we want to form pairs containing one number from the beginning of the sequence and one number from the end: 1+100, 2+99, 3+98, and so on. Why does that help? Because each of these pairs of numbers adds up to 101. And since there are 50 such pairs, we can very quickly figure out—without doing all 100 addition problems—that the sum of the first 100 positive integers is 50 x 101 = 5,050.
Adding the Integers From 1 to 1,000
But there’s nothing special about the first 100 integers. What if we want to know the sum of the first 1,000 integers instead? Well, let’s try using the same trick of adding up successive pairs of numbers from the beginning and end of the sum. So instead of 1 + 2 + 3 + … + 1,000, let’s rearrange things and turn the problem into: (1+1,000) + (2+999) + (3+998) + … + (500+501). Notice a similar pattern? Instead of adding up to 101, this time each pair adds up to 1,001. And since there are now 500 such pairs, we quickly see that the sum of the first 1,000 positive integers is 500 x 1,001 = 500,500.
So we now know that the same technique can be used to find the sum of the first 100 or 1,000 positive integers. But we don’t really want to keep going through this entire process for every possible number we’re adding up to. The question is: Can we find some underlying pattern to make things easier?
Behold, Triangular Numbers!
To figure that out, let’s take a step back and see if we can find a pattern in the sequence of numbers we get when we add up the first 1 positive integer, then the first 2 positive integers, then 3, 4, 5, and so on. Adding up the first 1 positive integer is easy…it’s just 1. How about the first 2? Well, that’s just 1 + 2 = 3. The first 3 give 1 + 2 + 3 = 6, the first 4 add up to a total of 10, then comes 15, and so on.
So the sequence we get is 1, 3, 6, 10, 15, and on and on. Does that look a little familiar? If you go back to our discussion of Pascal’s Triangle, you’ll see that this is the very same sequence of numbers that appeared in that famous triangle’s third diagonal! Which tells us that the sum of the integers from 1 up to any number is always a triangular number—first 1, 3, 6, 10, then eventually 5,050; 500,500; and beyond.
How to Quickly Add the Integers From 1 to n
As we’ve talked about before, triangular numbers get their name from the fact that you can draw funny triangles using evenly spaced grids of triangular numbers of dots. The first such triangle has 1-dot-long legs and therefore contains 1 total dot, the second triangle has 2-dot-long legs and therefore contains 3 total dots, the third has 3-dot-long legs and contains 6 dots, and so on.
Remember, our goal here is to find a pattern that allows us to quickly calculate the sum of the integers from 1 up to any number. Since we’ve now seen that we get a triangular number every time we sum from 1 up to any integer, all we need to do to accomplish our mission is to figure out if there’s a way to quickly calculate the number of dots in a particular triangular number. In other words, if we can figure out how to quickly come up with the 200th, 500th, or nth triangular number, we will have also figured out the sum of all the positive integers from 1 up to 200, 500, or whatever else n may be. So how can we do it?
A Formula For Adding the Integers From 1 to n
It’s easiest to see how this works by getting out a sheet of paper and drawing a few triangles of dots that represent the first several triangular numbers. Now draw copies of each of these triangles flipped around 180 degrees and nested together with the original triangles like puzzle pieces. What does that give you?
Instead of triangles of dots, you should now have several n-dot-long by (n+1)-dot-long rectangles of dots—which means that each of your rectangles should contain n x (n+1) dots. That means that the first 1-dot x 2-dot rectangle will contain 2 total dots, the second 2-dot x 3-dot rectangle will contain 6 dots, the third will have 12 dots, the fourth will have 20 dots, and so on. What does each of these rectangles represent? If you think about it, you’ll see that they each contain twice the number of dots in the nth triangular number (since we stuck 2 triangles together). And this means, after another bit of thought, that the nth triangular number must be equal to n x (n+1) / 2.
That formula is exactly what we’ve been looking for! It immediately tells us that the sum of all the integers from 1 to 100 must equal 100 x 101 / 2 = 5,050 (just as we’ve found), that the sum of the integers from 1 to 200 must equal 200 x 201 / 2 = 20,100, and that the sum of all the integers from 1 up to any number n that your friends throw at you must equal n x (n+1) / 2.
Wrap Up
Okay, that’s all the math we have time for today. In the meantime, remember to become a fan of the Math Dude on Facebook where you’ll find lots of great math posted throughout the week. If you’re on Twitter, please follow me there, too. Finally, please send your math questions my way via Facebook, Twitter, or email at mathdude@quickanddirtytips.comcreate new email.
Until next time, this is Jason Marshall with The Math Dude’s Quick and Dirty Tips to Make Math Easier. Thanks for reading, math fans!