freeCodeCamp/curriculum/challenges/chinese/08-coding-interview-prep/rosetta-code/factors-of-an-integer.chine...

1.5 KiB

title id challengeType videoUrl localeTitle
Factors of an integer 597f1e7fbc206f0e9ba95dc4 5 整数因子

Description

编写一个返回正整数因子的函数。

这些因子是正整数,通过该正整数可以将被分解的数量除以产生正整数结果。

///

Instructions

Tests

tests:
  - text: <code>factors</code>是一种功能。
    testString: 'assert(typeof factors === "function", "<code>factors</code> is a function.");'
  - text: '<code>factors(45)</code>应该返回<code>[1,3,5,9,15,45]</code> 。'
    testString: 'assert.deepEqual(factors(45), ans[0], "<code>factors(45)</code> should return <code>[1,3,5,9,15,45]</code>.");'
  - text: '<code>factors(53)</code>应该返回<code>[1,53]</code> 。'
    testString: 'assert.deepEqual(factors(53), ans[1], "<code>factors(53)</code> should return <code>[1,53]</code>.");'
  - text: '<code>factors(64)</code>应该返回<code>[1,2,4,8,16,32,64]</code> 。'
    testString: 'assert.deepEqual(factors(64), ans[2], "<code>factors(64)</code> should return <code>[1,2,4,8,16,32,64]</code>.");'

Challenge Seed

function factors (num) {
  // Good luck!
}

After Test

console.info('after the test');

Solution

// solution required