Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/iterated-digits-squaring.chinese.md
2020-08-16 04:45:18 +05:30

1.8 KiB
Raw Blame History

title, id, challengeType, videoUrl, localeTitle
title id challengeType videoUrl localeTitle
Iterated digits squaring 5a23c84252665b21eecc7ec1 5 迭代的数字平方

Description

如果添加自然数大于零的整数的数字的平方则始终以1或89结尾
 15  - > 26  - > 40  - > 16  - > 37  - > 58  - > 89
7  - > 49  - > 97  - > 130  - > 10  - > 1 
编写一个函数该函数将数字作为参数并在执行上述过程后返回1或89。

Instructions

Tests

tests:
  - text: <code>iteratedSquare</code>应该是一个函数。
    testString: assert(typeof iteratedSquare=='function');
  - text: <code>iteratedSquare(4)</code>应该返回一个数字。
    testString: assert(typeof iteratedSquare(4)=='number');
  - text: <code>iteratedSquare(4)</code>应该返回<code>89</code> 。
    testString: assert.equal(iteratedSquare(4),89);
  - text: <code>iteratedSquare(7)</code>应该返回<code>1</code> 。
    testString: assert.equal(iteratedSquare(7),1);
  - text: <code>iteratedSquare(15)</code>应该返回<code>89</code> 。
    testString: assert.equal(iteratedSquare(15),89);
  - text: <code>iteratedSquare(20)</code>应该返回<code>89</code> 。
    testString: assert.equal(iteratedSquare(20),89);
  - text: <code>iteratedSquare(70)</code>应该返回<code>1</code> 。
    testString: assert.equal(iteratedSquare(70),1);
  - text: <code>iteratedSquare(100)</code>应该返回<code>1</code> 。
    testString: assert.equal(iteratedSquare(100),1);

Challenge Seed

function iteratedSquare (n) {
  // Good luck!
}

Solution

// solution required