# Project Euler Problem 6 Solution in Python

Do you need “Project Euler Problem 6 Solution Python” . We will discuss all the problems in Project Euler and try to solve them using Python. I have solved Project Euler Problem 5 Python as well.

The sum of the squares of the first ten natural numbers is,

1^{2}+ 2^{2}+ … + 10^{2}= 385The square of the sum of the first ten natural numbers is,

(1 + 2 + … + 10)^{2}= 55^{2}= 3025Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

So we have to solve this problem using Python.

I am assuming you have already installed Python 2.7.x. If not, you can download it from here.

Lets first of all open Python IDLE.

If we analyze the problem statement given here, we can see that we are asked to find difference between sum of squares and square of sum.

**Project Euler Problem 6 Solution Python | **

**Lets start! **

This is one of the easiest by far I think.

You simply create a list of squares from 1 to 100, sum them and save in a variable.

Now save the sum of 1 to 100 in a variable, square it.

Now print the difference, you get your answer.

num2 = sum([i*i for i in range(1,101)]) num = sum(range(1,101)) num = num * num print num - num2

Lets see if we got it right.

Yaay! We got this right. Thanks for reading.

project euler problem 7 solution python

Happy coding!