Project Euler #5: Smallest multiple

  • + 0 comments

    import sys def lcm(x, y): if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 return lcm t = int(input().strip()) for a0 in range(t): n = int(input().strip()) a=n for i in range(n-1,1,-1): a=lcm(a,i) print(a)