2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: a3bfc1673c0526e06d3ac698
|
|
|
|
|
title: Sum All Primes
|
|
|
|
|
isRequired: true
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
localeTitle: Sum All Primes
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-06-30 01:51:26 -07:00
|
|
|
|
<section id="description">将所有素数加起来并包括所提供的数字。素数被定义为大于1的数,并且只有两个除数,一个和一个除数。例如,2是素数,因为它只能被1和2整除。提供的号码可能不是主要的。如果卡住,请记得使用<a href="https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514" target="_blank">Read-Search-Ask</a> 。尝试配对程序。编写自己的代码。 </section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>sumPrimes(10)</code>应该返回一个数字。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(typeof sumPrimes(10), 'number');
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>sumPrimes(10)</code>应该返回17。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(sumPrimes(10), 17);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>sumPrimes(977)</code>应该返回73156。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(sumPrimes(977), 73156);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function sumPrimes(num) {
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sumPrimes(10);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
|
|
/section>
|