Intermediate Algorithm Scripting - Smallest Common Multiple Solution 1 does not work

Solution 1 shows me an error when I copy paste it and try it out. Probably it will work in a proper tool but I suggest to add working solutions here only :slight_smile:

Oh and please ignore the (wrong) performance time trial in the end :wink:

Your code so far

function smallestCommons2(arr) {
  // Setup
  const [min, max] = arr.sort((a, b) => a - b);
  const numberDivisors = max - min + 1;
  // Largest possible value for SCM
  let upperBound = 1;
  for (let i = min; i <= max; i++) {
    upperBound *= i;
  // Test all multiples of 'max'
  for (let multiple = max; multiple <= upperBound; multiple += max) {
    // Check if every value in range divides 'multiple'
    let divisorCount = 0;
    for (let i = min; i <= max; i++) {
      // Count divisors
      if (multiple % i === 0) {
        divisorCount += 1;
    if (divisorCount === numberDivisors) {
      return multiple;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/107.0.1418.52

Challenge: Intermediate Algorithm Scripting - Smallest Common Multiple

Link to the challenge:

It works for me. I suggest you try removing your broken timing test.

You probably also should not rename the function. The tests can’t call a function that isn’t there.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.