2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5900f3971000cf542c50feaa
|
|
|
|
|
challengeType: 5
|
|
|
|
|
title: 'Problem 43: Sub-string divisibility'
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
localeTitle: 问题43:子串可分性
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-02-18 01:40:55 +09:00
|
|
|
|
<section id="description">
|
|
|
|
|
数字1406357289是0到9的全数字,因为它是由0到9的每个数字以某种顺序组成的,但是它也具有相当有趣的子字符串可除性。
|
|
|
|
|
令d1为第一位数,d2为第二位数,依此类推。 这样,我们注意以下几点:
|
|
|
|
|
d2d3d4 = 406可被2整除
|
|
|
|
|
d3d4d5 = 063被3整除
|
|
|
|
|
d4d5d6 = 635可被5整除
|
|
|
|
|
d5d6d7 = 357可被7整除
|
|
|
|
|
d6d7d8 = 572被11整除
|
|
|
|
|
d7d8d9 = 728被13整除
|
|
|
|
|
d8d9d10 = 289被17整除
|
|
|
|
|
使用此属性查找所有0到9个泛数字的数字。
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Instructions
|
2020-02-18 01:40:55 +09:00
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2020-02-18 01:40:55 +09:00
|
|
|
|
- text: <code>substringDivisibility()</code>应该返回[1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289]。
|
|
|
|
|
testString: assert.deepEqual(substringDivisibility(), [ 1430952867, 1460357289, 1406357289, 4130952867, 4160357289, 4106357289 ]);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function substringDivisibility() {
|
|
|
|
|
// Good luck!
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
substringDivisibility();
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
|
|
|
|
</section>
|