Project Euler #5: Smallest multiple

  • + 0 comments

    import math from functools import reduce

    def lcm(a, b): return abs(a*b) // math.gcd(a, b)

    def lcm_of_range(n): return reduce(lcm, range(1, n+1))

    Input handling

    t = int(input().strip()) for _ in range(t): n = int(input().strip()) result = lcm_of_range(n) print(result)