You are viewing a single comment's thread. Return to all comments →
Python 3:
#!/bin/python3 import sys def findGCD(a,b): while b!=0: remainder = a%b a=b b=remainder return a def lcmUsingGCD(a,b): return abs(a*b)//findGCD(a,b) def numLCM(n): lcm=1 for i in range(2, n+1): lcm = lcmUsingGCD(lcm, i) print(lcm) t = int(input().strip()) for a0 in range(t): n = int(input().strip()) numLCM(n)
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 3: