0

What is the algorithm of this?

2520 is the least integer divisible by numbers 1 to 10. Write a java programme to find the least divisible integer by numbers 1 to 20

10th Mar 2019, 4:09 AM
Nipun Pramuditha
Nipun Pramuditha - avatar
2 odpowiedzi
+ 19
● That will be LCM {1,2,3, ...,10} // I believe you want least +ve integer, else 0 and -ve integer can also satisfy the condition. ● fast way to do it, 1,2,3,4,5 comes as factors in 6,8,9 & 10. so you can exclude those 1,2,3,4,5 as will get counted in 6, 8, 9, 10. so LCM{1, 2, 3, ..., 10} will be reduced to LCM{6, 7, 8, 9, 10}. ● After that you can Find LCM of those numbers.
10th Mar 2019, 4:19 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 22
Go through these links : ● How to find LCM : http://www.math.com/school/subject1/lessons/S1U3L3DP.html ● Finding LCM of multiple numbers : https://www.geeksforgeeks.org/lcm-of-given-array-elements/amp/ ● one more way : https://www.geeksforgeeks.org/finding-lcm-two-array-numbers-without-using-gcd/amp/ //I don't know much of algorithm, but I believe we only need definition of LCM & give it a try with making our logic after some observations. //so I advice you to see 1st link only 👍 ● see my above comment also for reducing the number of elements of which you have to find LCM. use % operator for that.
10th Mar 2019, 4:29 AM
Gaurav Agrawal
Gaurav Agrawal - avatar