Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-40-champernownes-constant.md

871 B
Raw Blame History

id, title, challengeType, videoUrl
id title challengeType videoUrl
5900f3941000cf542c50fea7 问题40Champernowne的常数 5

--description--

通过连接正整数创建无理小数: 0.12345678910 1 112131415161718192021 ...可以看出小数部分的 12位是1.如果*d n*代表小数部分的 n位,找到值以下表达式。 d 1 ×d 10 ×d 100 ×d 1000 ×d 10000 ×d 100000 ×d 1000000

--hints--

champernownesConstant(100)应该返回5。

assert.strictEqual(champernownesConstant(100), 5);

champernownesConstant(1000)应该返回15。

assert.strictEqual(champernownesConstant(1000), 15);

champernownesConstant(1000000)应该返回210。

assert.strictEqual(champernownesConstant(1000000), 210);

--solutions--