Skip to content

Commit ba91224

Browse files
Add type hints and default args for Project Euler problem 5 (TheAlgorithms#2982)
* add type hints and default args for problem 5 * Update sol1.py * Update sol2.py Co-authored-by: Dhruv <[email protected]>
1 parent f692fe7 commit ba91224

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: project_euler/problem_05/sol1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010

11-
def solution(n):
11+
def solution(n: int = 20) -> int:
1212
"""Returns the smallest positive number that is evenly divisible(divisible
1313
with no remainder) by all of the numbers from 1 to n.
1414

Diff for: project_euler/problem_05/sol2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
""" Euclidean GCD Algorithm """
1010

1111

12-
def gcd(x, y):
12+
def gcd(x: int, y: int) -> int:
1313
return x if y == 0 else gcd(y, x % y)
1414

1515

1616
""" Using the property lcm*gcd of two numbers = product of them """
1717

1818

19-
def lcm(x, y):
19+
def lcm(x: int, y: int) -> int:
2020
return (x * y) // gcd(x, y)
2121

2222

23-
def solution(n):
23+
def solution(n: int = 20) -> int:
2424
"""Returns the smallest positive number that is evenly divisible(divisible
2525
with no remainder) by all of the numbers from 1 to n.
2626

0 commit comments

Comments
 (0)