freeCodeCamp/curriculum/challenges/chinese/08-coding-interview-prep/project-euler/problem-277-a-modified-coll...

56 lines
1.7 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 5900f4811000cf542c50ff94
challengeType: 5
title: 'Problem 277: A Modified Collatz sequence'
videoUrl: ''
localeTitle: 问题277修改的Collatz序列
---
## Description
<section id="description">通过以下方式从起始值a1获得修改的整数Collatz序列 <p>如果a可以被3整除则a + 1 = an / 3.我们将此表示为一个大的向下步骤“D”。 </p><p>如果除以3得到1的余数则a + 1 =4an + 2/ 3。我们将其称为向上步骤“U”。 </p><p>如果除以3得到余数为2则a + 1 =2an-1/ 3.我们将这表示为一个小的向下步骤“d”。 </p><p>当某些a = 1时序列终止。 </p><p>给定任何整数我们可以列出步骤的顺序。例如如果a1 = 231则序列{an} = {231,77,51,17,11,7,10,14,9,3,1}对应于步骤“DdDddUUdDD”。 </p><p>当然还有其他序列以相同的序列“DdDddUUdDD ....”开头。例如如果a1 = 1004064则序列为DdDddUUdDDDdUDUUUdDdUUDDDUdDD。实际上1004064是以序列DdDddUUdDD开头的最小可能a1&gt; 106。 </p><p>从序列“UDDDUdddDDUDDddDdDddDDUDDdUUDd”开始的最小a1&gt; 1015是多少 </p></section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>euler277()</code>应该返回1125977393124310。
testString: 'assert.strictEqual(euler277(), 1125977393124310, "<code>euler277()</code> should return 1125977393124310.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function euler277() {
// Good luck!
return true;
}
euler277();
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>