@@ -0,0 +1,1510 @@
+from functools import reduce%0A%0Adef pf1(n, facts):%0A    i = 2%0A    while i %3C= n:%0A        if n %25 i == 0:%0A            facts.append(i)%0A            pf1(n // i, facts)%0A            break%0A        else:%0A            i += 1%0A%0Adef pf2(n):%0A    facts = %5B%5D%0A    i = 2%0A    while i %3C= n:%0A        if n %25 i == 0:%0A            #print(i)%0A            facts.append(i)%0A%0A            if n == i:%0A                break%0A%0A            n = n // i%0A            i = 2%0A        else:%0A            i += 1%0A%0A    return facts%0A%0A%0Adef allfacts(n):%0A    d = 2%0A    f = %5B%5D%0A    a = 0%0A    while d %3C= n:%0A        if(a %3E 0 and d %3E a):%0A            break%0A%0A        if n %25 d == 0:%0A            f.append(d)%0A            if a == 0:%0A                a = n // d%0A        d = d + 1%0A    %0A    f.insert(0, 1)%0A    f.append(n)%0A    %0A    return f%0A%0Adef lcm(nums):%0A    nums = %5B(int(n), pf2(int(n))) for n in nums_str.split()%5D%0A    d = dict()%0A    for n in nums:%0A        for p in n%5B1%5D:%0A            if p in d:%0A                if n%5B1%5D.count(p) %3E d%5Bp%5D:%0A                    d%5Bp%5D = n%5B1%5D.count(p)%0A            else:%0A                d%5Bp%5D = n%5B1%5D.count(p)%0A%0A    x = %5Bi%5B0%5D ** i%5B1%5D for i in d.items()%5D%0A    ans = reduce(lambda p, c: p * c, x)%0A%0A    return ans%0A%0Adef hcf(nums):%0A    s = set(allfacts(nums%5B0%5D))%0A%0A    for i in range(1, len(nums)):%0A        a = allfacts(nums%5Bi%5D)%0A        s = s.intersection(a)%0A%0A    return max(s)    %0A%0Aif __name__ == %22__main__%22:%0A    nums_str = input('Input nubers separated by space: ')%0A    nums = %5Bint(n) for n in nums_str.split()%5D%0A    print(f'LCM is %7Blcm(nums)%7D  HCF is %7Bhcf(nums)%7D')%0A

Create LCMHCF.py