# Project Euler | Problem 5 | Smallest Multiple

##
__Problem Description__ :

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?

##
__Concept__ :

Do you know how we got 2520? Answer is very simple if we will try to get LCM(1,2,3,4,5,6,7,8,9,10) then it is 2520. It means we have to find LCM of all the number from 1 to 20. Now question is how to get LCM of two number in Java? So check below algorithm.

##
__Algorithm__ :

We have to perform following steps for finding LCM of two numbers.

- Get HCM of two numbers because LCM * HCM = product of two numbers. If we will get HCM then we can easily find LCM also.
- By Euclidean algorithm we can find HCM.
- We got HCM, so LCM = (product of two numbers) / HCM.

##
__Java Program__ :

##
__Output__ :

##
__References__ :

https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/the-euclidean-algorithm

http://www.math.com/school/subject1/lessons/S1U3L3DP.html

Thank you friends, I hope you have clearly understood the solution of this problem. If you have any doubt, suggestion or query please feel free to comment below. You can also discuss this solution in our forum.

**Tags : Project Euler Problem 5, Solution in Java, Smallest Multiple, LCM, HCM, if else statement, while loop, for loop.**

Project Euler | Problem 5 | Smallest Multiple
Reviewed by Rohit Agarwal
on
12/17/2016
Rating:

The code of this project doesn't seem to be complicated. I expected, that it will be longer and more confused. Thank you for this information.

ReplyDeleteThank you

DeleteThank you for the assistance I only a beginner programmer and your posts come in handy when I have some troubles I can`t solve myself.

ReplyDelete