Files
freeCodeCamp/curriculum/challenges/chinese/08-coding-interview-prep/rosetta-code/hofstadter-q-sequence.chinese.md
Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

2.1 KiB
Raw Blame History

title, id, challengeType, videoUrl, localeTitle
title id challengeType videoUrl localeTitle
Hofstadter Q sequence 59637c4d89f6786115efd814 5 Hofstadter Q序列

Description

Hofstadter Q序列定义为:

$ Q1= Q2= 1\\ Qn= Q \ bignQn-1\ big+ Q \ bignQn-2\ quad n> 2. $

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

任务将Hofstadter Q Sequence方程实现为JavaScript

Instructions

Tests

tests:
  - text: <code>hofstadterQ</code>是一个函数。
    testString: assert(typeof hofstadterQ === 'function');
  - text: <code>hofstadterQ()</code>应该返回<code>integer</code>
    testString: assert(Number.isInteger(hofstadterQ(1000)));
  - text: <code>hofstadterQ(1000)</code>应该返回<code>502</code>
    testString: assert.equal(hofstadterQ(testCase[0]), res[0]);
  - text: <code>hofstadterQ(1500)</code>应该返回<code>755</code>
    testString: assert.equal(hofstadterQ(testCase[1]), res[1]);
  - text: <code>hofstadterQ(2000)</code>应该返回<code>1005</code>
    testString: assert.equal(hofstadterQ(testCase[2]), res[2]);
  - text: <code>hofstadterQ(2500)</code>应该返回<code>1261</code>
    testString: assert.equal(hofstadterQ(testCase[3]), res[3]);

Challenge Seed

function hofstadterQ (n) {
  // Good luck!
  return n;
}

After Test

console.info('after the test');

Solution

// solution required