__author__ = 'stevan'

from math import ceil, sqrt
from collections import Counter


def is_not_prime(n):
    for i in range(2, int(ceil(sqrt(n))) + 1):
        if n % i == 0 and n != i:
            return True
    return False


def get_next_prime(n):
    n = n + 1
    while is_not_prime(n):
        n = n + 1
    return n


def prime_factors(n):
    prime = 2
    factors = []

    while n > 1:

        if n % prime == 0:
            n = n / prime
            factors.append(prime)
        else:
            prime = get_next_prime(prime)

    return factors


def least_common_multiple():
    factors_of_lcm = []

    for i in range(2, 20):
        cntr_factors = Counter(factors_of_lcm)
        cntr_temp = Counter(prime_factors(i))

        for j in range(2, 20):
            if cntr_temp[j] > cntr_factors[j]:
                diff = cntr_temp[j] - cntr_factors[j]
                while diff > 0:
                    factors_of_lcm.append(j)
                    diff = diff - 1

    return reduce(lambda x, y: x * y, factors_of_lcm, 1)


if __name__ == "__main__":
    print "Least common multiple is %d." % (least_common_multiple())