freeCodeCamp/curriculum/challenges/portuguese/08-coding-interview-prep/project-euler/problem-40-champernownes-co...

60 lines
1.8 KiB
Markdown
Raw Normal View History

---
id: 5900f3941000cf542c50fea7
challengeType: 5
title: 'Problem 40: Champernowne"s constant'
videoUrl: ''
localeTitle: 'Problema 40: constante de Champernowne'
---
## Description
<section id="description"> Uma fração decimal irracional é criado pela concatenação dos inteiros positivos: <span style="display: block; text-align: center;">0,12345678910 <b style="color: red;">1</b> 112131415161718192021 ...</span> Pode ser visto que o <sup>12º</sup> dígito da parte fracionária é 1. Se <i>d <sub>n</sub></i> representa o <i>n</i> <sup>th</sup> dígitos da parte fracionária, encontrar o valor da seguinte expressão. <span style="display: block; text-align: center;">d <sub>1</sub> × d <sub>10</sub> × d <sub>100</sub> × d <sub>1000</sub> × d <sub>10000</sub> × d <sub>100000</sub> × d <sub>1000000</sub></span> </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>champernownesConstant(100)</code> deve retornar 5.
testString: 'assert.strictEqual(champernownesConstant(100), 5, "<code>champernownesConstant(100)</code> should return 5.");'
- text: <code>champernownesConstant(1000)</code> deve retornar 15.
testString: 'assert.strictEqual(champernownesConstant(1000), 15, "<code>champernownesConstant(1000)</code> should return 15.");'
- text: <code>champernownesConstant(1000000)</code> deve retornar 210.
testString: 'assert.strictEqual(champernownesConstant(1000000), 210, "<code>champernownesConstant(1000000)</code> should return 210.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function champernownesConstant(n) {
// Good luck!
return true;
}
champernownesConstant(100);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>