// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (16 votes, average: 5.00 out of 5)

Project Euler Solutions

Project Euler 13 Solution

Project Euler 13 Solution

Project Euler 13: Find the first ten digits of the sum of one-hundred 50-digit numbers.

Project Euler 13 Problem Description

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.

… {data continues}


The numbers to add were saved to a file, pe13.txt, read in, and summed. The sum was truncated keeping the first 10 digits.

Project Euler 13 Solution

Runs < 0.001 seconds in Python 2.7.
download arrowUse this link to get the Project Euler 13 Solution Python 2.7 source.


Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose define to reveal the answer.


    No afterthoughts yet.

We had to copy and paste the data from the problem description and save it to a file. Yeah, I know I already mentioned that, but I just need more content so I can get this paged indexed. Anyway, how is everything? Hope you doing well and I’m glad you stopped by. Oh, don’t worry, only 30 people in the last 5 years have ever ventured to this page, so our conversation is, more than likely, quite personal and mostly private.

Have a great day – and check out some of my other pages.

your friend,

June 8, 2014

Project Euler 13 Solution last updated


4 Responses to “Project Euler 13 Solution”

  1. can you explain “Only the first 11 digits of each of the 100 numbers are required to calculate the first 10 digits of the sum”?

    Posted by mingbo | July 22, 2014, 4:36 PM
    • Because the numbers are so big it becomes “noisy” in the lower digits so only 11 are required to get the top 10 in this case.

      But wait, this could fail if the magnitude of the addition set or size was much smaller.

      Consider the top 4 digits of the sum 999999 + 100001 = 1100000, which are 1100, but taking only the sum of the top 5 digits 99999 + 10000 = 10999 or 1099, a difference of 1. So, yes, I guess we should add all the digits to be sure we’re accurate, otherwise we could be off by one. Not very likely, but possible.

      You asked a good question!


      Posted by Mike Molony | July 22, 2014, 9:40 PM
      • for 100 50-digit, if we only check sum of first 11 digits, the offset could be 9(if all 12nd digit is 9) *100 / 100 (carry on to 10th) = 9 not 1.

        BTW, you blog is awesome, I will read them one by one.

        Posted by mingbo | July 23, 2014, 9:48 AM
      • Thanks for the kind words and thanks for pointing out the problem with the solution.

        Hope you enjoy the rest of the blog.

        Posted by Mike Molony | July 24, 2014, 12:04 AM

Post a comment