freeCodeCamp/curriculum/challenges/portuguese/08-coding-interview-prep/project-euler/problem-29-distinct-powers....

62 lines
1.8 KiB
Markdown
Raw Normal View History

---
id: 5900f3891000cf542c50fe9c
challengeType: 5
title: 'Problem 29: Distinct powers'
videoUrl: ''
localeTitle: 'Problema 29: Poderes distintos'
---
## Description
<section id="description"> Considere todas as combinações inteiras de ab para 2 ≤ a ≤ 5 e 2 ≤ b ≤ 5: 22 = 4, 23 = 8, 24 = 16, 25 = 32 32 = 9, 33 = 27, 34 = 81, 35 = 243 42 = 16, 43 = 64, 44 = 256, 45 = 1024 52 = 25, 53 = 125, 54 = 625, 55 = 3125 Se eles são então colocados em ordem numérica, com qualquer repetição removida, obtemos a seguinte seqüência de 15 termos distintos: 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125 Quantos termos distintos estão na sequência gerada por ab para 2 ≤ a ≤ n e 2 ≤ b ≤ n? </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>distinctPowers(15)</code> deve retornar 177.
testString: 'assert.strictEqual(distinctPowers(15), 177, "<code>distinctPowers(15)</code> should return 177.");'
- text: <code>distinctPowers(20)</code> deve retornar 324.
testString: 'assert.strictEqual(distinctPowers(20), 324, "<code>distinctPowers(20)</code> should return 324.");'
- text: <code>distinctPowers(25)</code> deve retornar 519.
testString: 'assert.strictEqual(distinctPowers(25), 519, "<code>distinctPowers(25)</code> should return 519.");'
- text: <code>distinctPowers(30)</code> deve retornar 755.
testString: 'assert.strictEqual(distinctPowers(30), 755, "<code>distinctPowers(30)</code> should return 755.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function distinctPowers(n) {
// Good luck!
return n;
}
distinctPowers(30);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>