File tree Expand file tree Collapse file tree 5 files changed +15
-27
lines changed Expand file tree Collapse file tree 5 files changed +15
-27
lines changed Original file line number Diff line number Diff line change 11"""
2- Problem:
2+ Problem 6: https://projecteuler.net/problem=6
33
44The sum of the squares of the first ten natural numbers is,
55 1^2 + 2^2 + ... + 10^2 = 385
1515"""
1616
1717
18- def solution (n : int ) -> int :
18+ def solution (n : int = 100 ) -> int :
1919 """Returns the difference between the sum of the squares of the first n
2020 natural numbers and the square of the sum.
2121
@@ -27,6 +27,8 @@ def solution(n: int) -> int:
2727 41230
2828 >>> solution(50)
2929 1582700
30+ >>> solution()
31+ 25164150
3032 """
3133 sum_of_squares = 0
3234 sum_of_ints = 0
Original file line number Diff line number Diff line change 11"""
2- Problem:
2+ Problem 6: https://projecteuler.net/problem=6
33
44The sum of the squares of the first ten natural numbers is,
55 1^2 + 2^2 + ... + 10^2 = 385
1515"""
1616
1717
18- def solution (n : int ) -> int :
18+ def solution (n : int = 100 ) -> int :
1919 """Returns the difference between the sum of the squares of the first n
2020 natural numbers and the square of the sum.
2121
@@ -27,6 +27,8 @@ def solution(n: int) -> int:
2727 41230
2828 >>> solution(50)
2929 1582700
30+ >>> solution()
31+ 25164150
3032 """
3133 sum_cubes = (n * (n + 1 ) // 2 ) ** 2
3234 sum_squares = n * (n + 1 ) * (2 * n + 1 ) // 6
Original file line number Diff line number Diff line change 11"""
2- Problem:
2+ Problem 6: https://projecteuler.net/problem=6
33
44The sum of the squares of the first ten natural numbers is,
55 1^2 + 2^2 + ... + 10^2 = 385
1616import math
1717
1818
19- def solution (n : int ) -> int :
19+ def solution (n : int = 100 ) -> int :
2020 """Returns the difference between the sum of the squares of the first n
2121 natural numbers and the square of the sum.
2222
@@ -28,6 +28,8 @@ def solution(n: int) -> int:
2828 41230
2929 >>> solution(50)
3030 1582700
31+ >>> solution()
32+ 25164150
3133 """
3234 sum_of_squares = sum ([i * i for i in range (1 , n + 1 )])
3335 square_of_sum = int (math .pow (sum (range (1 , n + 1 )), 2 ))
Original file line number Diff line number Diff line change 11"""
2- Problem:
2+ Problem 6: https://projecteuler.net/problem=6
33
44The sum of the squares of the first ten natural numbers is,
55 1^2 + 2^2 + ... + 10^2 = 385
1515"""
1616
1717
18- def solution (n : int ) -> int :
18+ def solution (n : int = 100 ) -> int :
1919 """Returns the difference between the sum of the squares of the first n
2020 natural numbers and the square of the sum.
2121
@@ -27,7 +27,7 @@ def solution(n: int) -> int:
2727 41230
2828 >>> solution(50)
2929 1582700
30- >>> solution(100 )
30+ >>> solution()
3131 25164150
3232 """
3333 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