diff --git a/project_euler/problem_01/sol1.py b/project_euler/problem_01/sol1.py index e81156edaee4..0b3babccce19 100644 --- a/project_euler/problem_01/sol1.py +++ b/project_euler/problem_01/sol1.py @@ -6,8 +6,9 @@ """ -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -25,4 +26,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol2.py b/project_euler/problem_01/sol2.py index 8041c7ffa589..26b75ad96c16 100644 --- a/project_euler/problem_01/sol2.py +++ b/project_euler/problem_01/sol2.py @@ -6,8 +6,9 @@ """ -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -21,7 +22,9 @@ def solution(n): sum = 0 terms = (n - 1) // 3 - sum += ((terms) * (6 + (terms - 1) * 3)) // 2 # sum of an A.P. + + # sum of an A.P. + sum += ((terms) * (6 + (terms - 1) * 3)) // 2 terms = (n - 1) // 5 sum += ((terms) * (10 + (terms - 1) * 5)) // 2 terms = (n - 1) // 15 @@ -30,4 +33,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol3.py b/project_euler/problem_01/sol3.py index c0bcbc06ec83..ce93413152e3 100644 --- a/project_euler/problem_01/sol3.py +++ b/project_euler/problem_01/sol3.py @@ -6,7 +6,7 @@ """ -def solution(n): +def solution(n: int = 10) -> int: """ This solution is based on the pattern that the successive numbers in the series follow: 0+3,+2,+1,+3,+1,+2,+3. @@ -57,4 +57,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol4.py b/project_euler/problem_01/sol4.py index e01dc977d8cf..9032e782921a 100644 --- a/project_euler/problem_01/sol4.py +++ b/project_euler/problem_01/sol4.py @@ -6,8 +6,9 @@ """ -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -44,4 +45,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol5.py b/project_euler/problem_01/sol5.py index bd96d965f92d..82e41de4bfe3 100644 --- a/project_euler/problem_01/sol5.py +++ b/project_euler/problem_01/sol5.py @@ -8,8 +8,9 @@ """A straightforward pythonic solution using list comprehension""" -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -25,4 +26,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol6.py b/project_euler/problem_01/sol6.py index c9f94b9f77c8..b46c162b0c2c 100644 --- a/project_euler/problem_01/sol6.py +++ b/project_euler/problem_01/sol6.py @@ -6,8 +6,9 @@ """ -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -31,4 +32,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10)) diff --git a/project_euler/problem_01/sol7.py b/project_euler/problem_01/sol7.py index a0510b54c409..9475741375c6 100644 --- a/project_euler/problem_01/sol7.py +++ b/project_euler/problem_01/sol7.py @@ -6,8 +6,9 @@ """ -def solution(n): - """Returns the sum of all the multiples of 3 or 5 below n. +def solution(n: int = 10) -> int: + """ + Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 @@ -29,4 +30,4 @@ def solution(n): if __name__ == "__main__": - print(solution(int(input().strip()))) + print(solution(10))