Пример #1
0
def problem5(n):
    """
    Returns the smallest integer such that every m <= n divides it
    """
    accounted_for = set([1])
    result = 1
    for i in generate_primes_sieve(n + 1):
        # We iterate through all available numbers, accounting for the
        # powers of all numbers we see. Our result need only take into account
        # the highest power of any number we look at
        if i not in accounted_for:
            index = 0
            while i ** (index + 1) <= n:
                index += 1
                accounted_for.add(i ** index)
            result *= i ** index

    return result