Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

See original GitHub issue

#### Challenge Name

https://www.freecodecamp.org/challenges/smallest-common-multiple

#### Issue Description

My code failed the last test, but passed with `// noprotect` in the top. I figured it out when reading this post. My suggestion is to add a line in the description about `// noprotect`. Or to update the error message to ask people to make a more efficient algorithm. Otherwise people make inefficient algorithms like mine would be quite confused why it does not pass.

Thanks!

### Issue Analytics

• State:
• Created 6 years ago

1reaction
charlottetancommented, Oct 22, 2018

I’m not able to reproduce the issue with the code snippets in this thread, this issue can probably be closed.

0reactions
mpisterscommented, Jul 19, 2018

I have also this issue with my code (not very optimised):

``````function smallestCommons(arr){
const par1 = arr[0];
const par2 = arr[1];
let isDividable = false;
let range = false;
let number = 1;
while(!isDividable){
let diff1 = number % par1;
let diff2 = number % par2;
if (number % par1 === 0 && number % par2 === 0 && diff1 === diff2 ){
const start = par1 >= par2 ? par2 : par1;
const end = par1 >= par2 ? par1 : par2;
for(let i = start; i < end; i++){
if (number % i === diff1){
range = true;
} else {
range = false;
break;
}
}
if (range){
isDividable = true;
}
}
number++;
}
return number - 1;
}

console.log("does it work?", smallestCommons([23,18]));
``````

When I run this in the chrome browser it works, but in freecodecamp it doesn’t. I also added // no protect but doesn’t seem to work.

#### Top Results From Across the Web

Smallest Common Multiple - Infinite Loop - Stack Overflow
I think the first thing to do is read up on how to find the LCM of two numbers, setting aside the task...
Least common multiple (video) - Khan Academy
Sal finds the LCM ( least common multiple ) of 12 and 36, and of 12 and 18. He shows how to do...
Least common multiple review (article) | Khan Academy
LCM stands for least common multiple. The least common multiple of two numbers is the smallest number that is a multiple of both...
Smallest Common Multiple Test Case Bug
I debugged the code in Chrome Inspect element and the code passes all the test cases mentioned below the question. When I run...
Least Common Multiple - Math is Fun
The smallest positive number that is a multiple of two or more numbers. ... Example: Least Common Multiple of 3 and 5: List...

#### Troubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free