示例#1
0
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)
示例#2
0
'''
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}.")
示例#3
0
import euler

least = euler.lcm(1, 2)

for x in range(3, 21):
    least = euler.lcm(least, x)

print(least)
示例#4
0
from euler import lcm
print lcm(*range(1, 21))
示例#5
0
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))
示例#6
0
def divisible_by_all(N):
    result = 1
    for n in range(1, N + 1):
        result = lcm(result, n)
    return int(result)
示例#7
0
def calculate():

    return str(euler.lcm(20))