loading...
Cover image for Smallest multiple - Project Euler Solution

Smallest multiple - Project Euler Solution

codeperfectplus profile image CodePerfectPlus Updated on ・1 min read

Problem Solving Series(For Interview) (9 Part Series)

1) Multiples of 3 and 5 - Project Euler Solution 2) Two sum - Leet Code Solution 3 ... 7 3) Check for Armstrong Number 4) Largest palindrome product - Project Euler Solution 5) Smallest multiple - Project Euler Solution 6) Sum square difference - Project Euler Solution 7) 10001st prime - Project Euler Soution 8) Sieve of Eratosthenes 9) Bubble Sort Implementation in Python

Smallest multiple - Project Euler Solution

Topic: Smallest multiple

Problem Statement:

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

You can find the original question here -> Project Euler

Smallest multiple - Project Euler Solution in python

from math import gcd
def lcm(a,b):
    "Calculate the lowest common multiple of two integers a and b"
    return a*b//gcd(a,b)

from functools import reduce

result = reduce(lcm, range(1,11))
print(result)

Share Your Solutions for smallest multiple

Problem Solving Series(For Interview) (9 Part Series)

1) Multiples of 3 and 5 - Project Euler Solution 2) Two sum - Leet Code Solution 3 ... 7 3) Check for Armstrong Number 4) Largest palindrome product - Project Euler Solution 5) Smallest multiple - Project Euler Solution 6) Sum square difference - Project Euler Solution 7) 10001st prime - Project Euler Soution 8) Sieve of Eratosthenes 9) Bubble Sort Implementation in Python

Posted on by:

codeperfectplus profile

CodePerfectPlus

@codeperfectplus

Skilled in Data Science, Machine Learning, Deep Learning, As Well As Web Development Knowledge. React ❤️ to encourage Author.

Discussion

markdown guide