question-mark
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.

Smallest Common Multiple -- add a note about // noprotect

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:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

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.

Read more comments on GitHub >

github_iconTop 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...
Read more >
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...
Read more >
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...
Read more >
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...
Read more >
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...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

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

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found