From 6a5a022082eead9cdb4d248181d07da38894d69f Mon Sep 17 00:00:00 2001 From: Suyash Gupta Date: Thu, 8 Oct 2020 08:50:11 +0530 Subject: [PATCH] Add type hints and default args for Project Euler problem 5 (#2982) * add type hints and default args for problem 5 * Update sol1.py * Update sol2.py Co-authored-by: Dhruv --- 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 f8d83fc12..a347d6564 100644 --- a/project_euler/problem_05/sol1.py +++ b/project_euler/problem_05/sol1.py @@ -8,7 +8,7 @@ remainder) by all of the numbers from 1 to N? """ -def solution(n): +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. diff --git a/project_euler/problem_05/sol2.py b/project_euler/problem_05/sol2.py index 5aa84d21c..57b4cc823 100644 --- a/project_euler/problem_05/sol2.py +++ b/project_euler/problem_05/sol2.py @@ -9,18 +9,18 @@ remainder) by all of the numbers from 1 to N? """ 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 = 20) -> int: """Returns the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to n.