Skip to content

Commit a46620c

Browse files
author
Kalpana Jangra
committed
Fixed Project Euler Problem 01: Fixes #2786
1 parent 437c725 commit a46620c

File tree

7 files changed

+29
-21
lines changed

7 files changed

+29
-21
lines changed

project_euler/problem_01/sol1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"""
77

88

9-
def solution(n):
10-
"""Returns the sum of all the multiples of 3 or 5 below n.
9+
def solution(n: int = 10) -> int:
10+
"""
11+
Returns the sum of all the multiples of 3 or 5 below n.
1112
1213
>>> solution(3)
1314
0
@@ -25,4 +26,4 @@ def solution(n):
2526

2627

2728
if __name__ == "__main__":
28-
print(solution(int(input().strip())))
29+
print(solution(10))

project_euler/problem_01/sol2.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"""
77

88

9-
def solution(n):
10-
"""Returns the sum of all the multiples of 3 or 5 below n.
9+
def solution(n: int = 10) -> int:
10+
"""
11+
Returns the sum of all the multiples of 3 or 5 below n.
1112
1213
>>> solution(3)
1314
0
@@ -21,7 +22,9 @@ def solution(n):
2122

2223
sum = 0
2324
terms = (n - 1) // 3
24-
sum += ((terms) * (6 + (terms - 1) * 3)) // 2 # sum of an A.P.
25+
26+
# sum of an A.P.
27+
sum += ((terms) * (6 + (terms - 1) * 3)) // 2
2528
terms = (n - 1) // 5
2629
sum += ((terms) * (10 + (terms - 1) * 5)) // 2
2730
terms = (n - 1) // 15
@@ -30,4 +33,4 @@ def solution(n):
3033

3134

3235
if __name__ == "__main__":
33-
print(solution(int(input().strip())))
36+
print(solution(10))

project_euler/problem_01/sol3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88

9-
def solution(n):
9+
def solution(n: int = 10) -> int:
1010
"""
1111
This solution is based on the pattern that the successive numbers in the
1212
series follow: 0+3,+2,+1,+3,+1,+2,+3.
@@ -57,4 +57,4 @@ def solution(n):
5757

5858

5959
if __name__ == "__main__":
60-
print(solution(int(input().strip())))
60+
print(solution(10))

project_euler/problem_01/sol4.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"""
77

88

9-
def solution(n):
10-
"""Returns the sum of all the multiples of 3 or 5 below n.
9+
def solution(n: int = 10) -> int:
10+
"""
11+
Returns the sum of all the multiples of 3 or 5 below n.
1112
1213
>>> solution(3)
1314
0
@@ -44,4 +45,4 @@ def solution(n):
4445

4546

4647
if __name__ == "__main__":
47-
print(solution(int(input().strip())))
48+
print(solution(10))

project_euler/problem_01/sol5.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"""A straightforward pythonic solution using list comprehension"""
99

1010

11-
def solution(n):
12-
"""Returns the sum of all the multiples of 3 or 5 below n.
11+
def solution(n: int = 10) -> int:
12+
"""
13+
Returns the sum of all the multiples of 3 or 5 below n.
1314
1415
>>> solution(3)
1516
0
@@ -25,4 +26,4 @@ def solution(n):
2526

2627

2728
if __name__ == "__main__":
28-
print(solution(int(input().strip())))
29+
print(solution(10))

project_euler/problem_01/sol6.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"""
77

88

9-
def solution(n):
10-
"""Returns the sum of all the multiples of 3 or 5 below n.
9+
def solution(n: int = 10) -> int:
10+
"""
11+
Returns the sum of all the multiples of 3 or 5 below n.
1112
1213
>>> solution(3)
1314
0
@@ -31,4 +32,4 @@ def solution(n):
3132

3233

3334
if __name__ == "__main__":
34-
print(solution(int(input().strip())))
35+
print(solution(10))

project_euler/problem_01/sol7.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"""
77

88

9-
def solution(n):
10-
"""Returns the sum of all the multiples of 3 or 5 below n.
9+
def solution(n: int = 10) -> int:
10+
"""
11+
Returns the sum of all the multiples of 3 or 5 below n.
1112
1213
>>> solution(3)
1314
0
@@ -29,4 +30,4 @@ def solution(n):
2930

3031

3132
if __name__ == "__main__":
32-
print(solution(int(input().strip())))
33+
print(solution(10))

0 commit comments

Comments
 (0)