freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-an.../intermediate-algorithm-scri.../smallest-common-multiple.ch...

2.4 KiB
Raw Blame History

id title isRequired challengeType videoUrl localeTitle
ae9defd7acaf69703ab432ea Smallest Common Multiple true 5 最小的共同多重

Description

找到所提供参数的最小公倍数可以均匀地除以这些参数以及这些参数之间范围内的所有序号。范围将是两个数字的数组不一定按数字顺序排列。例如如果给定1和3找到1和3的最小公倍数它们也可以被1到3 之间的所有数字整除。这里的答案是6.记得使用Read-Search-Ask如果你得到卡住。尝试配对程序。编写自己的代码。

Instructions

Tests

tests:
  - text: '<code>smallestCommons([1, 5])</code>应返回一个数字。'
    testString: 'assert.deepEqual(typeof smallestCommons([1, 5]), "number", "<code>smallestCommons([1, 5])</code> should return a number.");'
  - text: '<code>smallestCommons([1, 5])</code>应该返回60。'
    testString: 'assert.deepEqual(smallestCommons([1, 5]), 60, "<code>smallestCommons([1, 5])</code> should return 60.");'
  - text: '<code>smallestCommons([5, 1])</code>应该返回60。'
    testString: 'assert.deepEqual(smallestCommons([5, 1]), 60, "<code>smallestCommons([5, 1])</code> should return 60.");'
  - text: '<code>smallestCommons([2, 10])</code> 2,10 <code>smallestCommons([2, 10])</code>应返回2520。'
    testString: 'assert.deepEqual(smallestCommons([2, 10]), 2520, "<code>smallestCommons([2, 10])</code> should return 2520.");'
  - text: '<code>smallestCommons([1, 13])</code> 1,13 <code>smallestCommons([1, 13])</code>应返回360360。'
    testString: 'assert.deepEqual(smallestCommons([1, 13]), 360360, "<code>smallestCommons([1, 13])</code> should return 360360.");'
  - text: '<code>smallestCommons([23, 18])</code> 23,18 <code>smallestCommons([23, 18])</code>应返回6056820。'
    testString: 'assert.deepEqual(smallestCommons([23, 18]), 6056820, "<code>smallestCommons([23, 18])</code> should return 6056820.");'

Challenge Seed

function smallestCommons(arr) {
  return arr;
}


smallestCommons([1,5]);

Solution

// solution required