+ 3

Challenge: Least Common Multiple.

Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters. The range will be an array of two numbers that will not necessarily be in numerical order. Examples: smallestCommonM([1,3]) //output:6 smallestCommonM([5,1]) //output:60 smallestCommonM([1,13]) //output:360360 Demo: range [1,3] : 1,2,3 1:1,2,3,4,5,6,7... 2:1,2,6,8... 3:1,3,6,9.. "6 is the smallest common multiple" Have fun! references: https://en.wikipedia.org/wiki/Least_common_multiple https://www.freecodecamp.org/challenges/smallest-common-multiple

17th Sep 2017, 1:47 AM
ysraelcon
ysraelcon - avatar
9 Respuestas
+ 7
Challenge accepted! I'm going to try it on tomorrow! 😄👍
16th Sep 2017, 5:12 PM
Zephyr Koo
Zephyr Koo - avatar
16th Sep 2017, 8:58 PM
m abrate
m abrate - avatar
+ 6
Here's my C# implementation ✌ LINQ One-Liner〰 Enumerable.Range( Math.Min(num1, num2), Math.Abs(num1 - num2) + 1 ).Aggregate((x, y) => GetLCM(x, y)) Enjoy! https://code.sololearn.com/c0zX4TVSky39/?ref=app
17th Sep 2017, 4:26 AM
Zephyr Koo
Zephyr Koo - avatar
+ 4
heres mine ## detailed explaination included https://code.sololearn.com/cEe63KWTx3oW/?ref=app ##this is a smaller // highly efficient//non-detailed version. https://code.sololearn.com/c2RfN8tQXDgc/?ref=app
16th Sep 2017, 6:36 PM
sayan chandra
sayan chandra - avatar
+ 3
heres my THIRD VERSION ONE LINER https://code.sololearn.com/cY7MZPEKD4xD/?ref=app
16th Sep 2017, 8:59 PM
sayan chandra
sayan chandra - avatar
+ 3
js: https://code.sololearn.com/Wbc4rKzV7xLM/?ref=app If js then I paste Forest.js via Math.lcm that I made java: https://code.sololearn.com/cAgXJJE9VEbL/?ref=app
17th Sep 2017, 2:46 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
https://code.sololearn.com/ctT6jbsAlzxl/?ref=app
16th Sep 2017, 6:30 PM
VcC
VcC - avatar
16th Sep 2017, 10:18 PM
VcC
VcC - avatar
+ 1
Here you go. Checks for valid input https://code.sololearn.com/cQpaOnQvGD3b/?ref=app
17th Sep 2017, 6:20 AM
Vari93
Vari93 - avatar