project-euler-100

[RADIOACTIVE] solutions to the first 100 challenges of project euler
git clone git://git.figbert.com/project-euler-100.git
Log | Files | Refs | README

problem006.py (575B)


      1 # problemName = "Sum square difference"
      2 # problemNum = 6
      3 # solutionBy = "FIGBERT"
      4 # language = "Python"
      5 # dateCompleted = "24/01/2020"
      6 
      7 if __name__ == "__main__":
      8     sum_of_the_squares = 0
      9     square_of_the_sum = 0
     10     for i in range(1, 101):
     11         sum_of_the_squares += i**2
     12         square_of_the_sum += i
     13     square_of_the_sum = square_of_the_sum**2
     14     answer = square_of_the_sum - sum_of_the_squares
     15     print((
     16         "The difference between the sum of the squares of the first one "
     17         "hundred natural numbers and the square of the sum is %s" % answer
     18     ))