Task: List the sum of all numbers between 7,777, and 70,000, where the numbers are divisible by 7.
Identification of the problem
The crux of this problem is to break the larger numbers down, into smaller sets, or groups, so that we can try and identify some type of pattern to work with. To solve this problem, we’ll need to calculate the sum of all the numbers between 7,777, and 70,000, but only for those numbers that are divisible by seven.
We’ll need some type of chart to help us understand the numbers we’re working with. It would be unrealistic for us to list all the numbers between 7,777, and 70,000, so we’ll work with a smaller list:
7,777 + 7,784 + 7,791 + … + 69,986 + 69,993 + 70,000
The numbers we’ll be working with are listed above. I’ve used an ellipse, to signify that there are missing numbers. This is much more practical than trying to list all the numbers. The list shows that the numbers start at 7,777, and continue, counting by seven, until the number 70,000, has been reached.
The problem asks us for the sum of all the numbers that are divisible by seven. Using this information, we can dramatically decrease the size of our list, as I have done above, by incrementing the numbers by seven.
Basic math skills will tell us that the number 7,778, is between 7,777, and 70,000; however, we’re not interested in that number, because it’s not divisible by seven. By incrementing the list by seven, I’ve excluded all the numbers that will have no effect on the outcome of this problem.
Now, we need to find the sum of all the numbers in our list. I could add them all manually, either in my head, or by using a calculator; however, this would take an outrageous amount of time, and isn’t a very practical solution.
We’re going to use a more logical method to find the answer to this question. So, the first thing we’ll need to do, is look for data, in the number list, that we can work with. Let’s try to alternate extremes on the number list, and see what happens. We’ll take the smallest number in the list, and add it to the largest number in the list:
7,777 + 70,000 = 77,777
After doing this, we can see that the answer is 77,777; but does that number have any significance? Let’s find out by alternating extremes again. We’ll take the next number, from each side, and add them together, just to test the result:
7,784 + 69,993 = 77,777
It appears that we’ve gotten the same result again; both calculations resulted in the number: 77,777. Let’s try alternating extremes one more time, and see if we get the same result:
7,791 + 69,986 = 77,777
Now that we’re able to produce the same answer three times in a row, it’s probably safe to assume that this is not a coincidence. It seems that, by alternating extremes, we can produce the same number every time.
We now have a number that appears to show up every time, but what does this number mean, and does it have any significance in solving this problem? The answer is: Yes! I’ll show you why…
First, look at the diagram I’ve drawn below. This should help you understand the calculations we’ve done thus far. I’ve drawn lines from the numbers that we’ve calculated, and listed the sum of those numbers, where the lines connect. As you can see, each result was the same:
I’ve taken the number 77,777, and labeled it as our “set sum”. The name itself doesn’t mean anything, but, it should help you understand the diagram, and our problem, a little better.
Let’s build an algorithm to help us solve the rest of the problem. There are probably many different algorithms that would work for a problem like this. I’m going to show you one method, that I know works.
Note: You can then use a program such as Microsoft Excel, to verify that the answer we came up with is correct.
The first thing we’re going to do, is create the outside set. To do this, we’re going to subtract numbers, instead of adding numbers. Because we’re looking for the sum of all numbers divisible by seven, let’s create the outside set, using the number seven. We’ll take the smallest number in the list, and subtract seven from it; this will be our outside set sum:
7,777 – 7 = 7,770
Per the calculation above, our outside set is: 7,777 – 7, and our outside set sum is: 7,770. The next thing we’ll do, is take the largest number in our list, and subtract our outside set sum. This is shown in the following calculation:
70,000 – (7,777 – 7) = 62,230
We’ve used two numbers to make up each set in this solution, and we were looking for all numbers that were divisible by seven. So, to find the next part of our algorithm, we’ll take the total number of numbers, (or elements) in each set, and multiply them by the number seven:
2 x 7 = 14
Now, let’s take the number 62,230, and divide it by the number 14, to get the next part of our algorithm; we’ll then multiply that number, by our set sum, to find the final answer to this problem:
62,230 ÷ 14 = 4,445
4,445 x 77,777 = 345,718,765
Our completed algorithm is listed below:
- We created a list which contained all the possible numbers.
- We created a diagram to give a better idea of how things fit together.
- We labeled our set sum, and outside set, to make them easier to understand.
- We created an algorithm to solve the final problem.
This is probably not the only algorithm that can be used to solve this problem, and I didn’t create this algorithm on the first try. It took an hour, or two, of guessing, checking, and moving things around, to get this to work.
One interesting thing you’ll probably notice, is that every number in this problem is divisible by seven. Even the final answer is divisible by seven. If you wanted to do this problem where each number was divisible by five, you’d want to rearrange a few of the numbers, so that you were using a five, instead of a seven.
If you want to test that my calculations are correct, you could write a computer program that would run through the calculations for you, or, if you’re not able to write your own program, you could use Microsoft Excel, to validate the answer.
Using Microsoft Excel, you can enter the number 7,777, into any cell in the program, and then use the “fill series” function, ending at the number 70,000, and using a step value of 7. This will create the same list I’ve created above. You’ll have all the numbers between 7,777, and 70,000, that are divisible by seven, listed in various cells. You can then use the “Sum” function, to add up all the numbers.
The answer shown in Excel, will most likely be an exponent value, so you’ll need to format the cell which contains the final answer into a “General Number” cell. This will display the full decimal value of the number.
Resources: Excel spreadsheet