--- id: 5900f3861000cf542c50fe99 challengeType: 5 videoUrl: '' title: 问题26:互惠周期 --- ## Description
单位分数在分子中包含1。给出分母2到10的单位分数的十进制表示:
二分之一 = 0.5
三分之一 = 0(3)
四分之一 = 0.25
1/5 = 0.2
六分之一 = 0.1(6)
七分之一 = 0(142857)
八分之一 = 0.125
九分之一 = 0(1)
一十分之一 = 0.1
其中0.1(6)表示0.166666 ...,并具有1位循环周期。可以看出, 1 / 7具有6位循环周期。找到d < n的值,其中1 / d包含其小数部分中最长的循环周期。
## Instructions
## Tests
```yml tests: - text: reciprocalCycles(700)应该返回659。 testString: assert(reciprocalCycles(700) == 659); - text: reciprocalCycles(800)应该返回743。 testString: assert(reciprocalCycles(800) == 743); - text: reciprocalCycles(900)应该返回887。 testString: assert(reciprocalCycles(900) == 887); - text: reciprocalCycles(1000)应该返回983。 testString: assert(reciprocalCycles(1000) == 983); ```
## Challenge Seed
```js function reciprocalCycles(n) { // Good luck! return n; } reciprocalCycles(1000); ```
## Solution
```js // solution required ``` /section>