File tree 5 files changed +15
-27
lines changed
5 files changed +15
-27
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- Problem:
2
+ Problem 6: https://projecteuler.net/problem=6
3
3
4
4
The sum of the squares of the first ten natural numbers is,
5
5
1^2 + 2^2 + ... + 10^2 = 385
15
15
"""
16
16
17
17
18
- def solution (n : int ) -> int :
18
+ def solution (n : int = 100 ) -> int :
19
19
"""Returns the difference between the sum of the squares of the first n
20
20
natural numbers and the square of the sum.
21
21
@@ -27,6 +27,8 @@ def solution(n: int) -> int:
27
27
41230
28
28
>>> solution(50)
29
29
1582700
30
+ >>> solution()
31
+ 25164150
30
32
"""
31
33
sum_of_squares = 0
32
34
sum_of_ints = 0
Original file line number Diff line number Diff line change 1
1
"""
2
- Problem:
2
+ Problem 6: https://projecteuler.net/problem=6
3
3
4
4
The sum of the squares of the first ten natural numbers is,
5
5
1^2 + 2^2 + ... + 10^2 = 385
15
15
"""
16
16
17
17
18
- def solution (n : int ) -> int :
18
+ def solution (n : int = 100 ) -> int :
19
19
"""Returns the difference between the sum of the squares of the first n
20
20
natural numbers and the square of the sum.
21
21
@@ -27,6 +27,8 @@ def solution(n: int) -> int:
27
27
41230
28
28
>>> solution(50)
29
29
1582700
30
+ >>> solution()
31
+ 25164150
30
32
"""
31
33
sum_cubes = (n * (n + 1 ) // 2 ) ** 2
32
34
sum_squares = n * (n + 1 ) * (2 * n + 1 ) // 6
Original file line number Diff line number Diff line change 1
1
"""
2
- Problem:
2
+ Problem 6: https://projecteuler.net/problem=6
3
3
4
4
The sum of the squares of the first ten natural numbers is,
5
5
1^2 + 2^2 + ... + 10^2 = 385
16
16
import math
17
17
18
18
19
- def solution (n : int ) -> int :
19
+ def solution (n : int = 100 ) -> int :
20
20
"""Returns the difference between the sum of the squares of the first n
21
21
natural numbers and the square of the sum.
22
22
@@ -28,6 +28,8 @@ def solution(n: int) -> int:
28
28
41230
29
29
>>> solution(50)
30
30
1582700
31
+ >>> solution()
32
+ 25164150
31
33
"""
32
34
sum_of_squares = sum ([i * i for i in range (1 , n + 1 )])
33
35
square_of_sum = int (math .pow (sum (range (1 , n + 1 )), 2 ))
Original file line number Diff line number Diff line change 1
1
"""
2
- Problem:
2
+ Problem 6: https://projecteuler.net/problem=6
3
3
4
4
The sum of the squares of the first ten natural numbers is,
5
5
1^2 + 2^2 + ... + 10^2 = 385
15
15
"""
16
16
17
17
18
- def solution (n : int ) -> int :
18
+ def solution (n : int = 100 ) -> int :
19
19
"""Returns the difference between the sum of the squares of the first n
20
20
natural numbers and the square of the sum.
21
21
@@ -27,7 +27,7 @@ def solution(n: int) -> int:
27
27
41230
28
28
>>> solution(50)
29
29
1582700
30
- >>> solution(100 )
30
+ >>> solution()
31
31
25164150
32
32
"""
33
33
sum_of_squares = n * (n + 1 ) * (2 * n + 1 ) / 6
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments