Files
freeCodeCamp/curriculum/challenges/chinese/08-coding-interview-prep/project-euler/problem-6-sum-square-difference.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

1.4 KiB
Raw Blame History

id, challengeType, title, videoUrl, localeTitle
id challengeType title videoUrl localeTitle
5900f3721000cf542c50fe85 5 Problem 6: Sum square difference 问题6求和方差

Description

前十个自然数的平方和是,
1 2 + 2 2 + ... + 10 2 = 385
前十个自然数之和的平方是,
1 + 2 + ... + 10 2 = 55 2 = 3025
因此前十个自然数的平方和与和的平方之间的差值为3025 - 385 = 2640.求出前n自然数的平方和与总和的平方之间的差值。

Instructions

Tests

tests:
  - text: <code>sumSquareDifference(10)</code>应该返回2640。
    testString: assert.strictEqual(sumSquareDifference(10), 2640);
  - text: <code>sumSquareDifference(20)</code>应该返回41230。
    testString: assert.strictEqual(sumSquareDifference(20), 41230);
  - text: <code>sumSquareDifference(100)</code>应该返回25164150。
    testString: assert.strictEqual(sumSquareDifference(100), 25164150);

Challenge Seed

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

sumSquareDifference(100);

Solution

// solution required