2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3911000cf542c50fea4
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
2020-10-01 17:54:21 +02:00
|
|
|
|
title: 问题37:可截断的素数
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
<section id="description"> 3797号有一个有趣的财产。作为素数本身,可以从左到右连续删除数字,并在每个阶段保持素数:3797,797,97和7.同样,我们可以从右到左工作:3797,379,37和3。找到从左到右和从右到左都可截断的唯一n(8 <= n <= 11)个素数之和。注意:2,3,5和7不被认为是可截断的素数。 </section>
|
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>truncatablePrimes(8)</code>应该返回1986年。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(truncatablePrimes(8) == 1986);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>truncatablePrimes(9)</code>应该返回5123。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(truncatablePrimes(9) == 5123);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>truncatablePrimes(10)</code>应该返回8920。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(truncatablePrimes(10) == 8920);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>truncatablePrimes(11)</code>应该返回748317。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(truncatablePrimes(11) == 748317);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function truncatablePrimes(n) {
|
|
|
|
|
// Good luck!
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
truncatablePrimes(11);
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
|
|
/section>
|