Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 27 lines (21 sloc) 0.663 kB
d6ecb55 Project Euler question 3 to 7
Akshar authored
1 #!/usr/bin/python
3db4382 @shabda Some pep-8 changes for p6
shabda authored
2
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
3
3db4382 @shabda Some pep-8 changes for p6
shabda authored
4 def sum_of_squares(number):
99bb8d3 @akshar-raaj doing things the pythonic way
authored
5 """sum=0
d6ecb55 Project Euler question 3 to 7
Akshar authored
6 for i in range(1,number+1):
7 square=i**2
8 sum=sum+square
99bb8d3 @akshar-raaj doing things the pythonic way
authored
9 return sum"""
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
10 l = [i * i for i in range(1, number + 1)]
99bb8d3 @akshar-raaj doing things the pythonic way
authored
11 return sum(l)
d6ecb55 Project Euler question 3 to 7
Akshar authored
12
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
13
3db4382 @shabda Some pep-8 changes for p6
shabda authored
14 def square_of_sum(number):
99bb8d3 @akshar-raaj doing things the pythonic way
authored
15 """sum=0
d6ecb55 Project Euler question 3 to 7
Akshar authored
16 for i in range(1,number+1):
17 sum=sum+i
99bb8d3 @akshar-raaj doing things the pythonic way
authored
18 return sum**2"""
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
19 l = range(1, number + 1)
20 return sum(l) ** 2
d6ecb55 Project Euler question 3 to 7
Akshar authored
21
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
22 sum_of_squre = sum_of_squares(100)
23 square_of_sum = square_of_sum(100)
3db4382 @shabda Some pep-8 changes for p6
shabda authored
24 print ("Difference between the sum of the squares of the first one hundred "
33021ec @akshar-raaj Confirm to pep8 guidelines
authored
25 "natural numbers and the square of the sum is "
26 "{0}".format(square_of_sum - sum_of_squre))
Something went wrong with that request. Please try again.