Skip to content

Instantly share code, notes, and snippets.

@betaprojects
Last active September 11, 2020 21:16
Show Gist options
  • Save betaprojects/15023eb4c38612585cdb8a403f2acfb8 to your computer and use it in GitHub Desktop.
Save betaprojects/15023eb4c38612585cdb8a403f2acfb8 to your computer and use it in GitHub Desktop.
Project Euler & HackerRank problem 5 solution: Smallest multiple - solved using Python
from math import gcd
from functools import reduce
def LCM(a, b):
return a // gcd(a, b) * b
N = int(input("The LCM for numbers 1 through "))
print ("is", reduce(LCM, range(N//2+1, N+1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment