def smallest_multiple(limit): """ finds the smallest multiple of numbers 1 to 'limit' limit (int): limit, inclusive returns (int): smallest multiple """ factors = remove_smaller_factors(range(1, limit+1)) return lcm(*factors)
''' Problem 5 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? ''' from euler import lcm numbers_1_to_20 = [number for number in range(1, 21)] answer = lcm(numbers_1_to_20) print(f"The least common multiple of all numbers 1-20 is {answer}.")
import euler least = euler.lcm(1, 2) for x in range(3, 21): least = euler.lcm(least, x) print(least)
from euler import lcm print lcm(*range(1, 21))
def fizzbuzz(a, b, limit): return int( sum_of_multiples_under(a, limit) + sum_of_multiples_under(b, limit) - sum_of_multiples_under(lcm(a, b), limit))
def divisible_by_all(N): result = 1 for n in range(1, N + 1): result = lcm(result, n) return int(result)
def calculate(): return str(euler.lcm(20))