You are viewing a single comment's thread. Return to all comments →
Python 2.7 Using reduce with lambda function to find LCM, I chose not to import gcd.
def _gcd(x,y): while y!=0: x,y=y,x%y return x t = int(raw_input()) for _ in range(t): n = int(raw_input()) print reduce(lambda x,y: x*y/_gcd(x,y), range(1,n+1))
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #5: Smallest multiple
You are viewing a single comment's thread. Return to all comments →
Python 2.7 Using reduce with lambda function to find LCM, I chose not to import gcd.