commit 41457cf3cbcb98262f3b9bed42d96ee7348418b7 parent fa05097c70083a6a88df4a7eb72ffcd1e702f798 Author: therealFIGBERT <figbertwelner@gmail.com> Date: Fri, 24 Jan 2020 11:35:41 -0800 Add solution to problem 6 Diffstat:
A | problem006.py | | | 14 | ++++++++++++++ |
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/problem006.py b/problem006.py @@ -0,0 +1,14 @@ +# problemName = "Sum square difference" +# problemNum = 6 +# solutionBy = "FIGBERT" +# language = "Python" +# dateCompleted = "24/01/2020" + +sumOfTheSquares = 0 +squareOfTheSum = 0 +for i in range(1, 101): + sumOfTheSquares += i**2 + squareOfTheSum += i +squareOfTheSum = squareOfTheSum**2 +answer = squareOfTheSum - sumOfTheSquares +print("The difference between the sum of the squares of the first one hundred natural numbers and the square of the sum is %s" % answer)