We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #5: Smallest multiple
Project Euler #5: Smallest multiple
Contest ends in
Sort by
recency
|
258 Discussions
|
Please Login in order to post a comment
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)
Python
Gets prime factors of each number from 1 to N and "adds them together"
C#
Swift efficient solution for N < 47: