project_euler.problem_005.sol2

Functions

lcm(→ int)

Least Common Multiple.

solution(→ int)

Returns the smallest positive number that is evenly divisible (divisible

Module Contents

project_euler.problem_005.sol2.lcm(x: int, y: int) int

Least Common Multiple.

Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b

>>> lcm(3, 15)
15
>>> lcm(1, 27)
27
>>> lcm(13, 27)
351
>>> lcm(64, 48)
192
project_euler.problem_005.sol2.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.

>>> solution(10)
2520
>>> solution(15)
360360
>>> solution(22)
232792560