From 76699375397cdd2771c187419650716d944c15e2 Mon Sep 17 00:00:00 2001 From: Suyash Gupta Date: Wed, 7 Oct 2020 19:22:01 +0530 Subject: [PATCH 1/3] add type hints and default args for problem 5 --- project_euler/problem_05/sol1.py | 2 +- project_euler/problem_05/sol2.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project_euler/problem_05/sol1.py b/project_euler/problem_05/sol1.py index f8d83fc12b71..c1d81f397d93 100644 --- a/project_euler/problem_05/sol1.py +++ b/project_euler/problem_05/sol1.py @@ -8,7 +8,7 @@ """ -def solution(n): +def solution(n: int = 10) -> int: """Returns the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to n. diff --git a/project_euler/problem_05/sol2.py b/project_euler/problem_05/sol2.py index 5aa84d21c8e8..56319a7f4b41 100644 --- a/project_euler/problem_05/sol2.py +++ b/project_euler/problem_05/sol2.py @@ -9,18 +9,18 @@ """ Euclidean GCD Algorithm """ -def gcd(x, y): +def gcd(x: int, y: int) -> int: return x if y == 0 else gcd(y, x % y) """ Using the property lcm*gcd of two numbers = product of them """ -def lcm(x, y): +def lcm(x: int, y: int) -> int: return (x * y) // gcd(x, y) -def solution(n): +def solution(n: int = 10) -> int: """Returns the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to n. From db6d7033ecdffca1e52cf0414bae1ebd7deec389 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 8 Oct 2020 08:44:44 +0530 Subject: [PATCH 2/3] Update sol1.py --- project_euler/problem_05/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_05/sol1.py b/project_euler/problem_05/sol1.py index c1d81f397d93..a347d6564fa7 100644 --- a/project_euler/problem_05/sol1.py +++ b/project_euler/problem_05/sol1.py @@ -8,7 +8,7 @@ """ -def solution(n: int = 10) -> int: +def solution(n: int = 20) -> int: """Returns the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to n. From a7a8ae6bb880b42a58e0845353803bd3657ea37c Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 8 Oct 2020 08:44:58 +0530 Subject: [PATCH 3/3] Update sol2.py --- project_euler/problem_05/sol2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_05/sol2.py b/project_euler/problem_05/sol2.py index 56319a7f4b41..57b4cc823d82 100644 --- a/project_euler/problem_05/sol2.py +++ b/project_euler/problem_05/sol2.py @@ -20,7 +20,7 @@ def lcm(x: int, y: int) -> int: return (x * y) // gcd(x, y) -def solution(n: int = 10) -> int: +def solution(n: int = 20) -> int: """Returns the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to n.