--- title: Hofstadter Q sequence id: 59637c4d89f6786115efd814 challengeType: 5 videoUrl: '' localeTitle: Hofstadter Q序列 --- ## Description

Hofstadter Q序列定义为:

$ Q(1)= Q(2)= 1,\\ Q(n)= Q \ big(nQ(n-1)\ big)+ Q \ big(nQ(n-2)),\ quad n> 2. $

它定义为Fibonacci序列 ,但Fibonacci序列中的下一个术语是前两个术语的总和,在Q序列中,前两个术语告诉您在Q序列中返回多远以找到两个数字总结以制作序列的下一个术语。

任务:将Hofstadter Q Sequence方程实现为JavaScript
## Instructions
## Tests
```yml tests: - text: hofstadterQ是一个函数。 testString: 'assert(typeof hofstadterQ === "function", "hofstadterQ is a function.");' - text: hofstadterQ()应该返回integer testString: 'assert(Number.isInteger(hofstadterQ(1000)), "hofstadterQ() should return integer");' - text: hofstadterQ(1000)应该返回502 testString: 'assert.equal(hofstadterQ(testCase[0]), res[0], "hofstadterQ(1000) should return 502");' - text: hofstadterQ(1500)应该返回755 testString: 'assert.equal(hofstadterQ(testCase[1]), res[1], "hofstadterQ(1500) should return 755");' - text: hofstadterQ(2000)应该返回1005 testString: 'assert.equal(hofstadterQ(testCase[2]), res[2], "hofstadterQ(2000) should return 1005");' - text: hofstadterQ(2500)应该返回1261 testString: 'assert.equal(hofstadterQ(testCase[3]), res[3], "hofstadterQ(2500) should return 1261");' ```
## Challenge Seed
```js function hofstadterQ (n) { // Good luck! return n; } ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```