+ 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
9 odpowiedzi
+ 7
Challenge accepted! I'm going to try it on tomorrow! 😄👍
+ 7
here is mine! 🐍
https://code.sololearn.com/cAoGr2yP6CL3/?ref=app
+ 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
+ 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
+ 3
heres my
THIRD VERSION
ONE LINER
https://code.sololearn.com/cY7MZPEKD4xD/?ref=app
+ 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
+ 2
https://code.sololearn.com/ctT6jbsAlzxl/?ref=app
+ 2
Even Shorter one https://code.sololearn.com/ctT6jbsAlzxl/?ref=app
+ 1
Here you go. Checks for valid input
https://code.sololearn.com/cQpaOnQvGD3b/?ref=app