I wrote all the numbers 0 - 1 000 000 on paper and added it all up. It took half a year. Would have gone faster but i had to sleep as well. I would say your method is superior to mine. Good thing is i had a lot of paper to burn for warmth this winter. My house were cold though because of me spending all my money on buying paper to solve this equation. I guess it was a paradoxical problem and solution.
Another simple way is by looking at how often each number happens in each position. From 000000 to 999999. It is obvious that all possible combinations of numbers occur, so all you need is the average value of each position. 4.5 is the average off the numbers 0 through 9. You have 6 positions, so 4.5*6 = 27 is the average value of your numbers. For a million numbers that gives 27 million, with the last 1 for the 1 million. This trick works on any arbitrary range with some care. For instance from 0 to 600000: For the last 5 digits, the old trick still works. For the first digit you need to average the range from 0-5 which is 2.5. That makes 5*4.5 for the last 5 positions (=22.5) and 2.5 for the first position to make an average of 25. 25 * 600000 = 15 million, plus the final 6 makes 15 000 006. I believe this method is quite a bit more flexible and easier to calculate since you're working with some very small and easy to comprehend numbers right up until the last step.
I got the right answer quickly, but with a different method. (More text to ensure a "Read more" button) (A little more) I considered six "digit slots", for which 0~999999 list all possibilities. Over ten numbers, the rightmost slot cycles through each digit 0~9, the sum of which is 45. This process repeats 100,000 times. Since each digit is independent, and all possibilities are used, each digit will appear 100,000 times in each slot. The sum of each ten is 45, there are 6 slots, and there are 100,000 groups of ten. 6*45*100,000=27,000,000. And of course, chuck on the +1 from 1,000,000, for 27,000,001
Manabender I did it pretty much the same way. We have 1 million possible numbers (including 000000, etc) So we have 6,000,000 digits, each digit, each value occurs an equal amount, so 6,000,000/10 = 600,000. So 600,000 * 0 + 600,000 * 1 + 600,000 * 2... etc + 1 = 27,000,001
Manabender Another way of seeing this. If you want to get the sum of every digit going from 1 to any number that fits the rule of x = 10^n ( while n is a positive integer ), you can follow this simple idea. Let n = logx, then the answer will be (45n x 10^(n-1)) + 1. For example, 1 to 1,000,000 or 1 to 100.
The answer is 27,000,001 because the digits from 1 to 9 add up to 45, and each occur 100000 times in each of the 6 digits spots, so 45*600000 and then add 1 for 1,000,000.
I think I was taught this trick a long time ago in one of my math classes, but I still was so pleased when I could remember "pairs, pairs!". It really is a testament to our brains and the power of our memories that a problem explained for 10 minutes sometime in the last 10 years could be recalled within minutes today. I didn't work it out myself, but the explanation stuck with me!
Your final explanation is somewhat (and unnecessarily) confusing. You're not adding 1 to 999998 to get 999999 (that sounds like you're adding values, not digits - which was what you told viewers to do), you're adding 1 to the result of 9+9+9+9+9+8. In other words, you're adding 1 to 53. Both things eventually give the same result because there are no carries, but it still sounds (from the way you describe it) like you're doing the wrong thing.
Nah...it made perfect sense how he explained it. Your critique is actually more "unnecessary". Your critique is the equivalent of saying..."no, 2 plus 2 doesnt equal 4...thats confusing. 4 is 1 plus 1 plus 1 plus 1."
Stefan For me, the non-mention of non-carries was/is not immediately _striking._ Addition, being associative, applies here with singular elegance. 1 is added to an end-8 and so forth leaving us with a stack of "999,999" -strings, each string added yielding 54, etc.
I came about a different method, though not nearly as fast but it was still fun working out. I considered that the sum from 1 to 9 of the digits was 45. In continuing this to 1-99 that sum was repeated 10 times in the ones digit and 10 times in the tens digit. The sum is also repeated 100 times in each the ones, tens, and hundreds digit in the sum from 1 to 999, and so on. This means the sum of 1-9 is repeated 100000 times in the sum 1-999999 in each digit. 45*100000*6=27000000, finally the +1.
The film (based on the book) "Measuring the World" beautifully illustrates this story right at the beginning :) It's a german film about the lives of Carl Friedrich Gauß and Alexander von Humboldt. I can recommend it (don't know about an english dub though)
If you think of the numbers from 1 to 100 as a triangle, the answer becomes quite evident and with Gausses intelligence, it is quite possible that he effectively did it.
To make it easier go from 0 to 999999. If you include leading zeros there'll be no effect on the sum but each number will have six digits. The average value of a digit is 4.5. A value of 4.5 per digit times six digits per number times a million numbers from 000000 to 999999 is 27 million. Add 1 for 1000000 and you get 27000001. I think that this method is a little easier but it's not really that different.
I thought you would do this a different way. Adding the digits 0+1+2+3+4+5+6+7+8+9=45, and from 0 to 999,999 has each of these digits appearing 100,000 times in each column, so those digits add to 45 X 100,000 X 6 = 27,000,000. Then, once again, add the 1 from 1,000,000.
Another fun way to do this problem is to consider the number of times the sum 1-9 (value of 45) can occur. From 0-9 it occurs once. From 0-99 it occurs 20 times. From 0-999,999 it occurs 600,000 times. From that you can develop a simple formula that gives 45*6*10^5 = 27,000,000 => +1 => 27,000,001. More generally, for any number that can be expressed as 10^n (where n is a natural number): 45*n*10^(n-1) + 1
I used a different approach: If you consider "1" as "000.001" and so on, you'll have one million 6-digit numbers. Considering each number appears an equal amount of times, you divide 6 million digits for 10. Then multiply 600.000 for 45 (the sum from 0-9) and get 27.000.000 and finally add 1
Dr. James, I think your assumption is wrong. At 05:50 You said, "If all those pairs equal the same thing we can now add these digits" but that is not true, the sum of digits does not necessary equal the sum of the actual numbers. So lets take an example. 100 is equal 50+50, it is also equal 1 + 99, but when you add the digits of both sums. 5+0+5+0 you get 10 , but when you add 1 + 9 + 9 you get 19. 100 is also equal to 9+9+9+9+9+9+9+9+9+19 (which digits sums to 91). In other words are alot of whole numbers that sums to a given value, however the sum of each sum's digit does not necessary equal. This means when you get the 999999 pairs and multiplied by half a million, you are only summing the digits 9. If you done that with by starting from a 1 instead of a zero , 1000001 multiplied by half a million, you will get a totally different result (much lesser though cuz you are summing 1s and 0s)
That's why he's adding them to 999 999 instead of the cool 1 000 000; 9 is the highest possible value of a digit, but given the way he goes through the list, he won't end up with any two digits that add up to anything higher than 9. ex. when his system gets to 203 456, that will be added to 796 543 to get 999 999, so working from right to left, it's 6+3 = 9, 5+4 = 9, 4+5 = 9, 3+6 = 9, 0+9 = 9, and 2+7 = 9
Oh, this is brilliant. I was just about to write a comment about how this couldn't work, then I saw how beautifully it actually does: When you add two numbers, a and b, the digit sum d(a+b) equals d(a) + d(b) as long as no pair of digits with the same order of magnitude exceeds 9 when adding together. d(9)=9 and d(2)=2, but d(9+2)=d(11) is just 2. This is what the zero does - it lets every pair sum up to 999,999, and this is why adding 1 to 999,999 or 1,000,000 wouldn't work.
Consider the last digit of every number from 1 to 1 million. 1/10 of those digits will be 0, 1/10 will be 1, 1/10 will be 2, all the way up to 9. Thus, their average will be (0+1+2...+8+9)/10=4.5. The same is true of the second last digits, the third last digits, all the way up to the sixth last digit. For the seventh digit, it will only be 1 in a single case (1000000). Thus, the sum of all the digits is 4.5*6*1000000+1=27000001.
This is how I would solve it, 000001 000002 000003 ... 999999 at each digit position there are equal number of 0s to 9s. Thus at each digit position the average digit would be 4.5, having 6 digit position and 1 million numbers would give the same result.
I did it a completely different way. The ones place will see as many 0s as 1s as 2s as 3s, etc. This means that there will be 100 thousand 0s, 1s, 2s, etc. 0 through 9 summed is 45; times 100,000 is 4,500,000. The first six digits all do this: the numbers from 0 to 9 is represented 100,000 times each. 4,500,000 times 6 is 27,000,000. Just remember to add "1" at the end from one million: 27,000,001.
+tibschris Ditto. Paused the video, worked it out in a couple minutes, then was really confused when he seemed to be adding the numbers, rather than the digits...made sense before long, though, and was probably a bit quicker than our way!
That's good! I did it by noticing how often each digit appeared from 0 to 999999. Adding 0s, each digit appears 100000 times in each position, 6 positions gives 600000. The sum of digits 1 through 9 is 45, so 45*600000 gives us 27000000. Then we add the 1 (from 1 million), and presto! :)
Just want to point out that every minute of video probably equates to anywhere from 2-10 minutes of footage. The average video length of these videos means that you can safely assume that these people have given the equivalent of an entire lecture per video. Dunno about the rest of you, but I think that's quite a bit of dedication. Keep it up folks, and keep watching! We can all stand to learn some.
is there anyone who doesn't know the story already and doesn't still want to watch good auld James Grime with his satisfied smile. but seriously, who doesn't know that story?
+Matt LeClerc total = 0 for i in 1..1000000 digitsString = i.to_s thisDigitsSum = 0 for e in digitsString.chars thisDigitsSum += e.to_i end total += thisDigitsSum end puts total
There is one problem I have with this. It's difficult to explain, and English is not my native language, but I'll try: Obviously it is taken for granted that all those number pairs that add up to 999,999 always have a digit sum of 54 when considered as a pair of two separate numbers. Why can we be so sure that the digit sum of the two separate numbers is transferred into the result of the addition? If we pick two random numbers, like e.g. 57 and 26, the digit sum of the two numbers considered separately is 20. Adding them together we get 83, and that has a digit sum of 11. So the digit sum is not always transferred into the result of an addition. How can we be sure that it always works out with all the pairs adding up to 999,999? Is there a proof for that?
8 років тому+2
+AREmrys Perhaps because in this way of adding two numbers it is always 999 999, so it never breaches the decimal structure/column, I mean it is never 5+6 or 8+ 3, It's always adding up to 9 in a column. e.g.: 500 000 + 499 999 = 999 999 the only calculation of digits here is this: 5+ 4 = 9
I guess I know what you missed- adding all digits of 999999 will be same as adding up all digits of 999996 and 3, but not 999997 and 3, because in addition some amount is carried over to next places (recall addition from primary school). So using clever pairs, it can be worked out. Notice that this works out even when other places are changed: 999989 and 10
almost similar to Niosus solution : for each of the 6 digits of the numbers 000000 to 999999, you have all digits from 0 to 9 used one tenth of the time, i.e 100000 times, so 100000 times * 6 digits * (1+2+3+4+5+6+7+8+9) = 27000000, add that 1 for 1000000 and you got it. That's the way I did it and finished before Gauss finishes in the story he tells :) Credit to Niosus for a solution that works for different numbers such as 6000000
i didn't know the story about how gauss calculated the total from 1 to 100. here's how i calculated the total digits from 1 to 1m: if you just look at the units, the pattern is simply 0,1,2,3...8-9 repeated one hundred thousand times (0,1,2,3,4,5,6,7,8,8,9, and then 10,11,12,13...). now, we know that 0+1+2+3..+9 =45 and that is repeated a hundred thousand times, so the total for the units only is 45,000. for the decades, the pattern is similar: 0 repeats 10 times, 1 repeats 10 times... 9 repeats 10 times, and then it starts again for 10,000 times. the sum is the same, though: 45,000! the for hundreds, the pattern is 0 repeated 100 times, 1 repeated 100 times and the the whole thing stats over again and is repeated 1000 times. all in all, there are 6 positions (units, decades, hundreds, thousands, tens of 000s, hundred of 000s), so the sum of the digits is 45,000*6=27,000,000!
Another thing which I think is interested. The 10th triangle number is 55. The 100th is 5050. The 1000 is 500500. the 1,000,000th is 500,000,500,000. It is always 5, followed by one less of the number of zeros in n, followed by 5 and one less of the number of zeros in n. There are other interesting patterns as well, but I don't remember many of them.
I was always fascinated by the fact that if you take an power of 10 and make it to the power of it's self, you get a 1 followed by (the number * original amount of zeros) zeros. 1000^1000 is 10^3000 and 1,000,000^1,000,000 = 10^6,000,000 etc.
Haha, this is so funny! We were taught this in math class just yesterday, and this video came up as recommended! ;D By the way, i love all of your videos on numberphile, keep 'em coming! :)
Gil Marquez ...What? I was explaining where 50*101 comes from using intuition. You'd have 50 pairs of 100, and the 50 in the middle wouldn't have a pair so you would add it.
cursedswordsman Actually no. You have 49 pairs of 100. 1 of 100 on its own. and 50 which has no pair. You cannot pair 100 with 0 because if you use 100/2 and get 50, 0 isn't included in those 100 numbers.
TheRu5tyNaiL You can force include it for the sake of calculation. Just do what Numberphile did but all pairs - 1, and add the 50 times you subtracted 1 back at the end. It's 5000 + 50. Tada~
Gil Marquez Well if I was to multiply that in my head, subconsciously I'd rearrange it in his form. I'd look at 50x101 and say "oh, that's 50 hundreds, plus an extra fifty. 5050." I guess if you're going to punch it into a calculator, it's easier to have only two terms multiplied, but I'd definitely say 50x100+50 is more intuitive, at least for my own personal thought process.
I was about to write a snotty comment about differences in English but i just checked my Oxford Dictionary and you are right. Its a preposition so should only replace the word multipliED. That's the first time the dictionary has been wrong so i have alerted the appropriate team. Times is in such common usage to mean multiply they will no doubt correct it.
When I was ten someone asked me to solve 999,999 * 999,999 in my head. I said 999,998,000,001 but I couldn't prove it was in my head because it was online and it took me a little bit. I multiplied 999,999 by 1,000,000 and subtracted 999,999 to get the number.
For the sum of all the digits of any number n=10^x (where x is a positive integer), the answer will be 4.5*n*log(n). I figured this one out after I decided to try to find the answer myself before finishing the video. My method was a bit more round about to get there, but it did simplify nicely.
Okay, I'm guessing the answer is 27000000, as there should be an even distribution of each digit. That means each digit appears 1/10 of the time in each, so there should be 100,000 series of 1+2+3+4+5+6+7+8+9 = 45 for each digit. There are 6 digits, so multiple it by 6. Or maybe 27000001, if include one million. Okay, time to watch video for answer.
I did a similar thing in math with all the numbers from 1 to 100, you simply add up all the pairs that equal a hundred (disregard 100 and 50) and you can work out that there are 49 hundreds, so 4900, add on the extra 150, and wala. You can use the same truck here, it all comes to 500 000 050 000.
I just want to come in a decade later and say that the solution in general with an evenly spaced set of numbers is to take the average of the first and last number and then multiply that number by the number of terms in the sequence.
1:15 When you said nine I randomly cut the deck of cards I was holding (from watching Numbery Card Trick - Numberphile) and right there was the nine of clubs. MINDBLOW
I arrived at the answer by a different method. I reasoned that in a list from 0 to 999999, each digit would appear 100000 times in each place. So (0+1+2+3+4+5+6+7+8+9) * 100000 * 6 + 1 = 27000001. I was so proud when he got the same answer. :-) It looks like bendswny was able to define the general formula below, although I find it slightly more intuitive to reason it this way than to think of it in terms of average digit value.
Well, pretty bad guess... Every number has the sum of its digits higher than one (otherwise it would be 0), so it's very clear that the result must be higher thant 1 million.
I'm at 2:12 and using a technique I learned. The technique states that when adding all numbers from 1 to x the answer is x(x+1)/2. So to add up all the numbers from 1 to 100 it'll be 100*101/2 = 10100/2 = 5050
OH YA, THIS STORY.... when i was very young like his age, school teacher ask to do the same.... so wad i did was,, 0 + 100 = 100, 1 + 99 = 100, 2 + 998 = 100 ...... 49 + 51 = 100 100 x 50 + 50 = 5050 i solve it in 10mins...
Corredor De Luz Thank you. I also summed the digits as they would appear in each column and got 4999996. The method he used combines numbers before parsing them into digits to be added.
I hadn't thought of that at all. I just figured out that every digit occurs in any one column 100,000 times, multiplied by the number of columns, 6, then summed the products of 600,000 and each number 1 to 9, which comes out to 27,000,000. +1 for the million, I suppose.
The sum of digits between 0 and 10^n can also be found using this formula: n*(10^n)*4.5+1, because the number of digits between 0 (or a number with n 0's) and (10^n)-1 (or a number with n 9's) is n*(10^n) and the average digit value is (0+1+2+3+4+5+6+7+8+9)/10=4.5, and then add one for 10^n.
It's a relief to know that even mathematicians sometimes say "times by" instead of "multiply by". That's gonna be my retort if anyone ever gives me a hard time about saying it.
every digit place sees every digit the same number of times, so for instance, the 100,000 place sees 0 up until 99,999, then 1 until 199,999, etc, so you can just take the average (4.5) times 1,000,000 and multiply by 6 (for the 6 decimal places) and then add 1 for the 1 in 1,000,000
Niiiiice that's exactly how i thought of it too :D You can write 1 as 000001, 100 as 000100 etc... You count the amount of decimals: 6*1 000 000. Thus you have each decimal 600 000 times, and then (using Gauss's formula ) multiply by (9*10/2) , then adding 1 and tadaa, 27 000 001
Big fan of the videos - don't know how I missed this one! I tackled the puzzle in a different way. If you write out all the numbers from 1 to 999,999, you'll have written down a total of 6million digits (including zeros, so 1=000001). Each digit is equally likely to appear (i.e. there are 600,000 ones and 600,000 fours etc.). Then you do: 600,000x1 + 600,000x2 + 600,000x3 + ... + 600,000x9 = 27,000,000 then add the 1 at the end from 1,000,000 and you get the answer :)
My solution was: (1+2+3+4+5+6+7+8+9)*100 000*6+1 sum(series(0-9))*A*B+1 A=number of times the series 0-9 pop up in one position. B=number of positions the series pop up in. The series is "repeated" the same number of times in the positions 1-6 from the right. +1 for the million
It can be written either way; in German, the letter "ß" is the same as writing two of a lower-case "s." For example, Bülowstraße can also be written as Bülowstrasse.
I took another attempt: I added up the numbers from 1 to 9, which equals 45. I figured out that each number appears 10^5 times on each digit from 1 to 999.999. Times that and times 6 for the number of digits + 1 for the 1.000.000. ...and I ended up with the correct result, but it surely took me a bit longer.
If anyone wants it, I was checking out Gauss' way of solving that problem, and it can be written as an equation; x+1*(x/0.5)=y (X = The highest number your adding up in sequence to | Y = your answer)
if you're referencing 1+2+3+4+5...+n = y, then the equation is a bit wrong. take for instance 100. 100+1*200 = 300. In case you got the parentheses wrong you'll still get 101 * 200 = 20200. You meant to put a multiplication symbol instead of the division. The correct equation is (x + 1) * (x / 2) which would be written as 0.5*(x^2 + x) just required a bit of proof reading. ;)
U can use nxn+1 _________ 2 If 1 to 50 then n=50 means 50x51 ________ = 25x51 =1275 2 If it is 1to 100 then n=100 100x101 __________= 50x101=5050 2 Means we can use this to find the sum
How I did it: From 000000 to 999999 there are 1000000 numbers and 6 digits per number so that's 6000000 digits. Since every digit occurs exactly 10.00% of the time, we can average the value of each digit to 4.5. 6000000*4.5=27000000. Then add the 1000000 (6 zeroes and 1) to get 27000001.
i did it the same way but somewhat simpler: the same digit of 10 numbers in a row always sums up to 45, so the same digit of one million sums up to 450'000. there are 6 digits, 6*450'000=2'700'000 +1 the 7th digit the million has.
my solution before i get to the answer in video :3 we have 6 digits that can be anything between 0 and 9 (to make 1 digit number you put a 5 0 and 1). on average the digit is gonna be worth 4.5 and theres a million 6 digit combinations + 1 for 1 000 000 so 4.5 x 1 000 000 + 1 = 4 500 001
I solved it, but I used a different method. I figured adding 1 through 9 = 45. Each place value will use each of those digits 100,000 times (cycling through at different rates). So 4,500,000 x 6 (# of 0's in 1,000,000) = 27,000,000. Then add the 1 from 1,000,000. It took me about 2 or 3 minutes. Fun puzzle!
incomplete - wanted is the sum of the digits of EACH number, but calculated was the sum of the digits of the sum of pairs - missing the prove that adding the digit sum of each number (of a pair) is the same as the digit sum of both numbers added. digitsum(1+99) digitsum(1) + digitsum(99)
I have used another method (but it is more complicated then the one in the video). I consider the digit as 000000 to 999999 (as adding a zero will not affect the result). For each digit, there are 100000 group of [0,1,2,3...,9]. Therefore, the answer could be 6 (digit) x 100000 (group) x 45 (from 0+1+2+...+9) + 1 (from 1000000) = 27000001.
"I'm gonna skip a few"
skips 999 991 numbers
he only skipped 999 990 numbers
Off by one error F-
Yeah this is my most liked comment and i made one tiny mistake
99 liked this comment about 999 990
100th like
I wrote all the numbers 0 - 1 000 000 on paper and added it all up. It took half a year. Would have gone faster but i had to sleep as well. I would say your method is superior to mine. Good thing is i had a lot of paper to burn for warmth this winter. My house were cold though because of me spending all my money on buying paper to solve this equation. I guess it was a paradoxical problem and solution.
ZixDays why
EightMonths wtf
U deserve a nobel prize man
Why tho?
after the same amount of time, i only have 288,300 XD
I'm a teacher, and I've been looking all over UA-cam for a good telling of the story of Gauss. Thank you!
Another simple way is by looking at how often each number happens in each position. From 000000 to 999999. It is obvious that all possible combinations of numbers occur, so all you need is the average value of each position. 4.5 is the average off the numbers 0 through 9. You have 6 positions, so 4.5*6 = 27 is the average value of your numbers. For a million numbers that gives 27 million, with the last 1 for the 1 million.
This trick works on any arbitrary range with some care. For instance from 0 to 600000: For the last 5 digits, the old trick still works. For the first digit you need to average the range from 0-5 which is 2.5. That makes 5*4.5 for the last 5 positions (=22.5) and 2.5 for the first position to make an average of 25. 25 * 600000 = 15 million, plus the final 6 makes 15 000 006.
I believe this method is quite a bit more flexible and easier to calculate since you're working with some very small and easy to comprehend numbers right up until the last step.
Niosus Used this method and forgot to multiply by 6. Ended up multiplying by 10 because a quick approximath told me I was an order of magnitude out.
I got the right answer quickly, but with a different method.
(More text to ensure a "Read more" button)
(A little more)
I considered six "digit slots", for which 0~999999 list all possibilities. Over ten numbers, the rightmost slot cycles through each digit 0~9, the sum of which is 45. This process repeats 100,000 times.
Since each digit is independent, and all possibilities are used, each digit will appear 100,000 times in each slot. The sum of each ten is 45, there are 6 slots, and there are 100,000 groups of ten. 6*45*100,000=27,000,000.
And of course, chuck on the +1 from 1,000,000, for 27,000,001
Manabender I did it pretty much the same way. We have 1 million possible numbers (including 000000, etc) So we have 6,000,000 digits, each digit, each value occurs an equal amount, so 6,000,000/10 = 600,000. So 600,000 * 0 + 600,000 * 1 + 600,000 * 2... etc + 1 = 27,000,001
WhatThyHex
moe joe What? Why is this relevant?
.
Manabender Another way of seeing this. If you want to get the sum of every digit going from 1 to any number that fits the rule of x = 10^n ( while n is a positive integer ), you can follow this simple idea. Let n = logx, then the answer will be (45n x 10^(n-1)) + 1. For example, 1 to 1,000,000 or 1 to 100.
The answer is 27,000,001 because the digits from 1 to 9 add up to 45, and each occur 100000 times in each of the 6 digits spots, so 45*600000 and then add 1 for 1,000,000.
U smart
There are a few other possible fast ways but none as fast as the one in the vid.
Bb
I like your way, it's the way I would have done it. Plus, he never demonstrates that the sum of digits in n (n
I think Epik's way is just as fast. Why wouldn't it be?
hmmm well 1 10 100 1,000 10,000 100,000 and 1,000,000 all equal 1. so the answer is at least 7.
We have a minimum!
@@OrangeC7 It also can't go over infinity, so somewhere in between huh?
Funny
@@mata5246 right
Somewhere between 7 and infinity-1...
This is the first time in a long time that I can remember someone explaining math and at the end I thought "oh that's so cool" 😊
The magic of james grime!
Why do numberphile's thumbnails look like the funniest memes . Like a huge equation and it just zooms in on some old painting, with distortion
I think I was taught this trick a long time ago in one of my math classes, but I still was so pleased when I could remember "pairs, pairs!". It really is a testament to our brains and the power of our memories that a problem explained for 10 minutes sometime in the last 10 years could be recalled within minutes today. I didn't work it out myself, but the explanation stuck with me!
I love it how enthusiastic he is in his videos! Great!
A great example of how in maths problems can become incredibly easier when you just write them differently.
For Gauss it was a 50 - 50 chance
Lol
Your final explanation is somewhat (and unnecessarily) confusing. You're not adding 1 to 999998 to get 999999 (that sounds like you're adding values, not digits - which was what you told viewers to do), you're adding 1 to the result of 9+9+9+9+9+8. In other words, you're adding 1 to 53. Both things eventually give the same result because there are no carries, but it still sounds (from the way you describe it) like you're doing the wrong thing.
as long as u are adding them up to 999999 each digit is added independently so the sum of digits is conserved.
Yeah he didn't mention that there are no carries which is not immediately obvious.
Nah...it made perfect sense how he explained it. Your critique is actually more "unnecessary". Your critique is the equivalent of saying..."no, 2 plus 2 doesnt equal 4...thats confusing. 4 is 1 plus 1 plus 1 plus 1."
Broken Wave, you should think that over
Stefan
For me, the non-mention of non-carries was/is not immediately _striking._
Addition, being associative, applies here with singular elegance. 1 is added to an end-8 and so forth leaving us with a stack of "999,999" -strings, each string added yielding 54, etc.
I came about a different method, though not nearly as fast but it was still fun working out.
I considered that the sum from 1 to 9 of the digits was 45. In continuing this to 1-99 that sum was repeated 10 times in the ones digit and 10 times in the tens digit. The sum is also repeated 100 times in each the ones, tens, and hundreds digit in the sum from 1 to 999, and so on. This means the sum of 1-9 is repeated 100000 times in the sum 1-999999 in each digit. 45*100000*6=27000000, finally the +1.
did the same and resulted in this formula: 45*(n*10^(n-1)) + 1 being 10^n the number up to which we want to count the digits.
Wouldn't this give you 45*10^1000005 if n=1000000 ?
+Art Artsen the number you want to count to is 1000000, which is 10^6, so it would give 45*(6*10^(6-1)) + 1
+Art Artsen if n = 1000000 you want to count up to 10^1000000
Oooh right, the way you phrased it threw me off
The film (based on the book) "Measuring the World" beautifully illustrates this story right at the beginning :)
It's a german film about the lives of Carl Friedrich Gauß and Alexander von Humboldt. I can recommend it (don't know about an english dub though)
I did it a different way to get the answer, i used a very complicated algorithm that some refer to as google
Gauss probably used Google too
@@Trias805 he made google back then just to google it tbh
If you think of the numbers from 1 to 100 as a triangle, the answer becomes quite evident and with Gausses intelligence, it is quite possible that he effectively did it.
4:44 "Let's just write out all the numbers first."
Oh, boy. Let me get some popcorn. *This is gonna be a while.*
01:40 Shoutout to Dr James for roasting Gauss's maths teacher. 🤣🤣
To make it easier go from 0 to 999999. If you include leading zeros there'll be no effect on the sum but each number will have six digits. The average value of a digit is 4.5. A value of 4.5 per digit times six digits per number times a million numbers from 000000 to 999999 is 27 million. Add 1 for 1000000 and you get 27000001.
I think that this method is a little easier but it's not really that different.
I thought you would do this a different way. Adding the digits 0+1+2+3+4+5+6+7+8+9=45, and from 0 to 999,999 has each of these digits appearing 100,000 times in each column, so those digits add to 45 X 100,000 X 6 = 27,000,000. Then, once again, add the 1 from 1,000,000.
1:10 doesn't he look really much like Matt?
Another fun way to do this problem is to consider the number of times the sum 1-9 (value of 45) can occur. From 0-9 it occurs once. From 0-99 it occurs 20 times. From 0-999,999 it occurs 600,000 times. From that you can develop a simple formula that gives 45*6*10^5 = 27,000,000 => +1 => 27,000,001. More generally, for any number that can be expressed as 10^n (where n is a natural number): 45*n*10^(n-1) + 1
To sum digits from number B to number A: (A^2 - B^2 + A + B) /2
I used a different approach: If you consider "1" as "000.001" and so on, you'll have one million 6-digit numbers. Considering each number appears an equal amount of times, you divide 6 million digits for 10. Then multiply 600.000 for 45 (the sum from 0-9) and get 27.000.000 and finally add 1
Dr. James, I think your assumption is wrong. At 05:50 You said, "If all those pairs equal the same thing we can now add these digits" but that is not true, the sum of digits does not necessary equal the sum of the actual numbers. So lets take an example. 100 is equal 50+50, it is also equal 1 + 99, but when you add the digits of both sums. 5+0+5+0 you get 10 , but when you add 1 + 9 + 9 you get 19. 100 is also equal to 9+9+9+9+9+9+9+9+9+19 (which digits sums to 91). In other words are alot of whole numbers that sums to a given value, however the sum of each sum's digit does not necessary equal. This means when you get the 999999 pairs and multiplied by half a million, you are only summing the digits 9. If you done that with by starting from a 1 instead of a zero , 1000001 multiplied by half a million, you will get a totally different result (much lesser though cuz you are summing 1s and 0s)
wouldn't you pair 1 with 98, in that case? (and, 0 with 99)
That's why he's adding them to 999 999 instead of the cool 1 000 000; 9 is the highest possible value of a digit, but given the way he goes through the list, he won't end up with any two digits that add up to anything higher than 9.
ex. when his system gets to 203 456, that will be added to 796 543 to get 999 999, so working from right to left, it's 6+3 = 9, 5+4 = 9, 4+5 = 9, 3+6 = 9, 0+9 = 9, and 2+7 = 9
So in summary...you simply misunderstood him.
Oh, this is brilliant. I was just about to write a comment about how this couldn't work, then I saw how beautifully it actually does:
When you add two numbers, a and b, the digit sum d(a+b) equals d(a) + d(b) as long as no pair of digits with the same order of magnitude exceeds 9 when adding together. d(9)=9 and d(2)=2, but d(9+2)=d(11) is just 2. This is what the zero does - it lets every pair sum up to 999,999, and this is why adding 1 to 999,999 or 1,000,000 wouldn't work.
Consider the last digit of every number from 1 to 1 million. 1/10 of those digits will be 0, 1/10 will be 1, 1/10 will be 2, all the way up to 9. Thus, their average will be (0+1+2...+8+9)/10=4.5. The same is true of the second last digits, the third last digits, all the way up to the sixth last digit. For the seventh digit, it will only be 1 in a single case (1000000). Thus, the sum of all the digits is 4.5*6*1000000+1=27000001.
This is how I would solve it,
000001
000002
000003
...
999999
at each digit position there are equal number of 0s to 9s. Thus at each digit position the average digit would be 4.5, having 6 digit position and 1 million numbers would give the same result.
Cool
Brilliant
I have a math project and need to get 3 ideas. I got all of them from your channel, one of the channels I will never unsubscribe to. Numberphile
I did it a completely different way.
The ones place will see as many 0s as 1s as 2s as 3s, etc. This means that there will be 100 thousand 0s, 1s, 2s, etc.
0 through 9 summed is 45; times 100,000 is 4,500,000.
The first six digits all do this: the numbers from 0 to 9 is represented 100,000 times each.
4,500,000 times 6 is 27,000,000.
Just remember to add "1" at the end from one million: 27,000,001.
+tibschris
same
PS: also 2016 XD
+tibschris Ditto. Paused the video, worked it out in a couple minutes, then was really confused when he seemed to be adding the numbers, rather than the digits...made sense before long, though, and was probably a bit quicker than our way!
I learned this when I was 12.. I've never forgotten Gauss' story since then
Poozle = Puzzle
Huuuuh.... British.....
2:12 that was the "poblem" he gave the people
@@ChrisBandyJazz come on, there's clearly an r there, it's just a bit silent
@@soupisfornoobs4081 no
That's good! I did it by noticing how often each digit appeared from 0 to 999999. Adding 0s, each digit appears 100000 times in each position, 6 positions gives 600000. The sum of digits 1 through 9 is 45, so 45*600000 gives us 27000000. Then we add the 1 (from 1 million), and presto! :)
Here we go: 1+2=3+3=6... Wait, this will take a while.
wait, you're onto something! what next?...
@@DrewKF I think after that comes 17
@@tonksdude 10
Just want to point out that every minute of video probably equates to anywhere from 2-10 minutes of footage. The average video length of these videos means that you can safely assume that these people have given the equivalent of an entire lecture per video. Dunno about the rest of you, but I think that's quite a bit of dedication. Keep it up folks, and keep watching! We can all stand to learn some.
Bruh Gauss's 5 century old formula's, theories and equations are still used in most modern engineering problems. It kinda blows my mind
Gauss was a 19th Century thinker, and there are mathematical discoveries from ancient times that are still in use.
is there anyone who doesn't know the story already and doesn't still want to watch good auld James Grime with his satisfied smile.
but seriously, who doesn't know that story?
I just cheated and wrote a program haha.
+Matt LeClerc ahahh the power of calculators :D
+Matt LeClerc ditto
+Matt LeClerc
total = 0
for i in 1..1000000
digitsString = i.to_s
thisDigitsSum = 0
for e in digitsString.chars
thisDigitsSum += e.to_i
end
total += thisDigitsSum
end
puts total
+Guilherme Biem What language is that????
Adriyaman Banerjee Ruby
I just wanted to say thank you for this video Numberphile; because of it, I got extra credit towards my final grade in my Calculus class today! :D
There is one problem I have with this. It's difficult to explain, and English is not my native language, but I'll try:
Obviously it is taken for granted that all those number pairs that add up to 999,999 always have a digit sum of 54 when considered as a pair of two separate numbers. Why can we be so sure that the digit sum of the two separate numbers is transferred into the result of the addition?
If we pick two random numbers, like e.g. 57 and 26, the digit sum of the two numbers considered separately is 20. Adding them together we get 83, and that has a digit sum of 11. So the digit sum is not always transferred into the result of an addition.
How can we be sure that it always works out with all the pairs adding up to 999,999? Is there a proof for that?
+AREmrys Perhaps because in this way of adding two numbers it is always 999 999, so it never breaches the decimal structure/column, I mean it is never 5+6 or 8+ 3, It's always adding up to 9 in a column.
e.g.: 500 000 + 499 999 = 999 999
the only calculation of digits here is this:
5+ 4 = 9
I guess I know what you missed- adding all digits of 999999 will be same as adding up all digits of 999996 and 3, but not 999997 and 3, because in addition some amount is carried over to next places (recall addition from primary school). So using clever pairs, it can be worked out. Notice that this works out even when other places are changed: 999989 and 10
almost similar to Niosus solution :
for each of the 6 digits of the numbers 000000 to 999999, you have all digits from 0 to 9 used one tenth of the time, i.e 100000 times, so 100000 times * 6 digits * (1+2+3+4+5+6+7+8+9) = 27000000, add that 1 for 1000000 and you got it. That's the way I did it and finished before Gauss finishes in the story he tells :)
Credit to Niosus for a solution that works for different numbers such as 6000000
surely you are a better mathematician than gausse then aren't you ?
Gauss tossing his slate to the teacher: 19th century mic drop.
i didn't know the story about how gauss calculated the total from 1 to 100. here's how i calculated the total digits from 1 to 1m: if you just look at the units, the pattern is simply 0,1,2,3...8-9 repeated one hundred thousand times (0,1,2,3,4,5,6,7,8,8,9, and then 10,11,12,13...). now, we know that 0+1+2+3..+9 =45 and that is repeated a hundred thousand times, so the total for the units only is 45,000. for the decades, the pattern is similar: 0 repeats 10 times, 1 repeats 10 times... 9 repeats 10 times, and then it starts again for 10,000 times. the sum is the same, though: 45,000! the for hundreds, the pattern is 0 repeated 100 times, 1 repeated 100 times and the the whole thing stats over again and is repeated 1000 times. all in all, there are 6 positions (units, decades, hundreds, thousands, tens of 000s, hundred of 000s), so the sum of the digits is 45,000*6=27,000,000!
+Carl Coppens You forgit to add the number 1 000 000. So it is 27 000 001
Tesser4ct nope. it's 27 000 000
+Carl Coppens I also solved in this way. But the answer is still 27 000 001. Number 1000000 is not included in that calculation.
+Carl Coppens You didn't include 1000000
+Carl Coppens 45,000*6 = 270.000, not 27.000.000
Another thing which I think is interested. The 10th triangle number is 55. The 100th is 5050. The 1000 is 500500. the 1,000,000th is 500,000,500,000. It is always 5, followed by one less of the number of zeros in n, followed by 5 and one less of the number of zeros in n. There are other interesting patterns as well, but I don't remember many of them.
*Writes a program to do it
Bengineer8 As someone who has started learning python, that's exactly what I did lol
Andrew Garcia Sadly all I know is TI basic. My calculator is still working on ti, even after a couple hours
digit_sum = 0
for n in range(1000000):
for digit in str(n):
digit_sum += int(digit)
print(digit_sum)
+sagiksp It won't work. You have to use range(1,1000001) instead.
Writing program takes time.
I was always fascinated by the fact that if you take an power of 10 and make it to the power of it's self, you get a 1 followed by (the number * original amount of zeros) zeros. 1000^1000 is 10^3000 and 1,000,000^1,000,000 = 10^6,000,000 etc.
I did for the 1+2+3...99+100
(100+1)/2x100
(100+1)/2=50.5x100=5050
Haha, this is so funny! We were taught this in math class just yesterday, and this video came up as recommended! ;D
By the way, i love all of your videos on numberphile, keep 'em coming! :)
Easier method: Pair 0 with 100, 1 with 99, ect. and you get 50 pairs of 100, but you have to add the 50 in the middle so it's 5,050.
so you think 50*100 + 50 is easier than 50*101? lol
Gil Marquez ...What? I was explaining where 50*101 comes from using intuition. You'd have 50 pairs of 100, and the 50 in the middle wouldn't have a pair so you would add it.
cursedswordsman Actually no. You have 49 pairs of 100. 1 of 100 on its own. and 50 which has no pair. You cannot pair 100 with 0 because if you use 100/2 and get 50, 0 isn't included in those 100 numbers.
TheRu5tyNaiL You can force include it for the sake of calculation. Just do what Numberphile did but all pairs - 1, and add the 50 times you subtracted 1 back at the end. It's 5000 + 50. Tada~
Gil Marquez Well if I was to multiply that in my head, subconsciously I'd rearrange it in his form. I'd look at 50x101 and say "oh, that's 50 hundreds, plus an extra fifty. 5050."
I guess if you're going to punch it into a calculator, it's easier to have only two terms multiplied, but I'd definitely say 50x100+50 is more intuitive, at least for my own personal thought process.
I was about to write a snotty comment about differences in English but i just checked my Oxford Dictionary and you are right. Its a preposition so should only replace the word multipliED.
That's the first time the dictionary has been wrong so i have alerted the appropriate team. Times is in such common usage to mean multiply they will no doubt correct it.
When I was ten someone asked me to solve 999,999 * 999,999 in my head. I said 999,998,000,001 but I couldn't prove it was in my head because it was online and it took me a little bit. I multiplied 999,999 by 1,000,000 and subtracted 999,999 to get the number.
PhigNewton1 u should have said "get rekt" after and walked off
For the sum of all the digits of any number n=10^x (where x is a positive integer), the answer will be 4.5*n*log(n).
I figured this one out after I decided to try to find the answer myself before finishing the video. My method was a bit more round about to get there, but it did simplify nicely.
Okay, I'm guessing the answer is 27000000, as there should be an even distribution of each digit. That means each digit appears 1/10 of the time in each, so there should be 100,000 series of 1+2+3+4+5+6+7+8+9 = 45 for each digit. There are 6 digits, so multiple it by 6. Or maybe 27000001, if include one million. Okay, time to watch video for answer.
I did a similar thing in math with all the numbers from 1 to 100, you simply add up all the pairs that equal a hundred (disregard 100 and 50) and you can work out that there are 49 hundreds, so 4900, add on the extra 150, and wala. You can use the same truck here, it all comes to 500 000 050 000.
I learn more here in 7 minutes than I did in 7 years of school! Wow, thanks Brady!
I just want to come in a decade later and say that the solution in general with an evenly spaced set of numbers is to take the average of the first and last number and then multiply that number by the number of terms in the sequence.
or just print(sum([sum(map(int,str(i))) for i in [x for x in range(1,1000001)]]))
What an elegant solution and great story.
all the digits in 1,000,000 add up to ... 1 ... 1 + 0 + 0 + 0 + 0 + 0 + 0 = 1
All the digits in one to a million, implying 1, a million, and all numbers inbetween.
Zombers
No, that's not what it implies.
Graviton1066 sorry, it implies it to people with a brain.
Its very poorly worded.
Graviton1066 have you ever heard the phrase "pick a number one to ten"? i know it implies it.
1:15 When you said nine I randomly cut the deck of cards I was holding (from watching Numbery Card Trick - Numberphile) and right there was the nine of clubs. MINDBLOW
I got 5050 in a second, I just assumed 50.5 was the average of all the numbers then multiplied that by 100
Sure you did
+Rambi “Rambi9000” Ok, cool.
Wow, that's like Jedi Accountant skills...
+Heisenberg GB Problem?
+NoriMori ego problem...
I arrived at the answer by a different method. I reasoned that in a list from 0 to 999999, each digit would appear 100000 times in each place. So (0+1+2+3+4+5+6+7+8+9) * 100000 * 6 + 1 = 27000001. I was so proud when he got the same answer. :-)
It looks like bendswny was able to define the general formula below, although I find it slightly more intuitive to reason it this way than to think of it in terms of average digit value.
Before I see, I'm gonna guess 1 million
+spaz cuber well i was wrong
I quessed 4.5 millions
Well, pretty bad guess... Every number has the sum of its digits higher than one (otherwise it would be 0), so it's very clear that the result must be higher thant 1 million.
I'm at 2:12 and using a technique I learned. The technique states that when adding all numbers from 1 to x the answer is x(x+1)/2. So to add up all the numbers from 1 to 100 it'll be 100*101/2
= 10100/2 = 5050
OH YA, THIS STORY.... when i was very young like his age, school teacher ask to do the same.... so wad i did was,,
0 + 100 = 100,
1 + 99 = 100,
2 + 998 = 100
...... 49 + 51 = 100
100 x 50 + 50 = 5050
i solve it in 10mins...
+pennyfish89 Oh ya,, btw,,, i wrote this comment before i finish watch this vid
+pennyfish89 Maybe one day you will contribute as much to mathematics as Gauss did!
+pennyfish89 2 + 998 = 1000
2+998 =1000
Also:
2 + 998 = 1,000
;D
Loved this one. Thanks!
It isn´t so hard...
The video is wrong, because 999990+10 it´s equal to 54 or to 46?
It´s just a little example, the right answer is 4.999.996
999.990 is paired with 9 giving 999.999
10 is paired with 999.989 giving 999.999
Corredor De Luz Thank you. I also summed the digits as they would appear in each column and got 4999996. The method he used combines numbers before parsing them into digits to be added.
I hadn't thought of that at all. I just figured out that every digit occurs in any one column 100,000 times, multiplied by the number of columns, 6, then summed the products of 600,000 and each number 1 to 9, which comes out to 27,000,000. +1 for the million, I suppose.
Love this show!!! I'm going to SHOOT the next person to say "timesed by..." though. :/
Carl Friedrich Gauss is the most underrated mathematician ever.. in 2023 who is in science field and earning should owe to this great genius
The sum of digits between 0 and 10^n can also be found using this formula:
n*(10^n)*4.5+1, because the number of digits between 0 (or a number with n 0's) and (10^n)-1 (or a number with n 9's) is n*(10^n) and the average digit value is (0+1+2+3+4+5+6+7+8+9)/10=4.5, and then add one for 10^n.
(x^2+x)/2 you can thank me later
The Skooma Cat That explains nothing to me.
Robert Brink I'll....just ask my teacher...in my native language...
Thank you, that cleared it up pretty well, I didn't realize I had skipped a pairing.
It's a relief to know that even mathematicians sometimes say "times by" instead of "multiply by". That's gonna be my retort if anyone ever gives me a hard time about saying it.
Well explained.Gauss has been the huge huge figure in the field of Mathematics.The all time great.
every digit place sees every digit the same number of times, so for instance, the 100,000 place sees 0 up until 99,999, then 1 until 199,999, etc, so you can just take the average (4.5) times 1,000,000 and multiply by 6 (for the 6 decimal places) and then add 1 for the 1 in 1,000,000
Niiiiice that's exactly how i thought of it too :D
You can write 1 as 000001, 100 as 000100 etc... You count the amount of decimals: 6*1 000 000. Thus you have each decimal 600 000 times, and then (using Gauss's formula ) multiply by (9*10/2) , then adding 1 and tadaa, 27 000 001
Big fan of the videos - don't know how I missed this one! I tackled the puzzle in a different way. If you write out all the numbers from 1 to 999,999, you'll have written down a total of 6million digits (including zeros, so 1=000001). Each digit is equally likely to appear (i.e. there are 600,000 ones and 600,000 fours etc.). Then you do:
600,000x1 + 600,000x2 + 600,000x3 + ... + 600,000x9 = 27,000,000 then add the 1 at the end from 1,000,000 and you get the answer :)
My solution was:
(1+2+3+4+5+6+7+8+9)*100 000*6+1
sum(series(0-9))*A*B+1
A=number of times the series 0-9 pop up in one position.
B=number of positions the series pop up in. The series is "repeated" the same number of times in the positions 1-6 from the right.
+1 for the million
It can be written either way; in German, the letter "ß" is the same as writing two of a lower-case "s."
For example, Bülowstraße can also be written as Bülowstrasse.
this is so damn genius. i wish i could get such awesome ideas
I took another attempt: I added up the numbers from 1 to 9, which equals 45.
I figured out that each number appears 10^5 times on each digit from 1 to 999.999.
Times that and times 6 for the number of digits + 1 for the 1.000.000.
...and I ended up with the correct result, but it surely took me a bit longer.
If anyone wants it, I was checking out Gauss' way of solving that problem, and it can be written as an equation;
x+1*(x/0.5)=y
(X = The highest number your adding up in sequence to | Y = your answer)
if you're referencing 1+2+3+4+5...+n = y, then the equation is a bit wrong. take for instance 100. 100+1*200 = 300. In case you got the parentheses wrong you'll still get 101 * 200 = 20200.
You meant to put a multiplication symbol instead of the division. The correct equation is (x + 1) * (x / 2) which would be written as 0.5*(x^2 + x)
just required a bit of proof reading. ;)
Oh yeah, I saw that now. Thanks for mentioning it. I put 0.5 in because it was multiplication first, but I changed it. Should be /2, not 0.5
Thanks. Took me a while to get to that conclusion but I can see it now. :-)
U can use nxn+1
_________
2
If 1 to 50 then n=50 means
50x51
________ = 25x51 =1275
2
If it is 1to 100 then n=100
100x101
__________= 50x101=5050
2
Means we can use this to find the sum
Nice method!
Gauss : **throws the slate at the teacher's table after finding the answer**
Also Gauss: *WHY DO I HEAR BOSS MUSIC??*
Gauss is said to be so smart, he could solve matrices in third grade
How I did it: From 000000 to 999999 there are 1000000 numbers and 6 digits per number so that's 6000000 digits. Since every digit occurs exactly 10.00% of the time, we can average the value of each digit to 4.5. 6000000*4.5=27000000. Then add the 1000000 (6 zeroes and 1) to get 27000001.
Thats the most bloody brilliant thing on earth
I did, too. He told the "riddle", and then I just paused the video and figured it out, quite easily. xD
i did it the same way but somewhat simpler:
the same digit of 10 numbers in a row always sums up to 45, so the same digit of one million sums up to 450'000. there are 6 digits, 6*450'000=2'700'000 +1 the 7th digit the million has.
If I was a math teacher I would do this every year in my class.
my solution before i get to the answer in video :3
we have 6 digits that can be anything between 0 and 9 (to make 1 digit number you put a 5 0 and 1). on average the digit is gonna be worth 4.5 and theres a million 6 digit combinations + 1 for 1 000 000 so 4.5 x 1 000 000 + 1 = 4 500 001
I solved it, but I used a different method. I figured adding 1 through 9 = 45. Each place value will use each of those digits 100,000 times (cycling through at different rates). So 4,500,000 x 6 (# of 0's in 1,000,000) = 27,000,000. Then add the 1 from 1,000,000. It took me about 2 or 3 minutes. Fun puzzle!
incomplete - wanted is the sum of the digits of EACH number, but calculated was the sum of the digits of the sum of pairs - missing the prove that adding the digit sum of each number (of a pair) is the same as the digit sum of both numbers added. digitsum(1+99) digitsum(1) + digitsum(99)
digit_sum = 0
for n in range(1000000):
for digit in str(n):
digit_sum += int(digit)
print(digit_sum)
quick get this man a slate and chalk
I have used another method (but it is more complicated then the one in the video). I consider the digit as 000000 to 999999 (as adding a zero will not affect the result). For each digit, there are 100000 group of [0,1,2,3...,9]. Therefore, the answer could be 6 (digit) x 100000 (group) x 45 (from 0+1+2+...+9) + 1 (from 1000000) = 27000001.