Tuesday, 8 November 2016

Hackerrank , Project Euler #5: Smallest multiple

Project Euler #5: Smallest multiple


from fractions import gcd
def lcm(numbers):
    return reduce(lambda x, y: (x*y)/gcd(x,y), numbers)
t=input()
for i in range(0,t):
    print lcm(range(1,input()+1))

No comments:

Post a Comment