Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions chapters/03-funcoes.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,17 @@ Aqui está uma solução recursiva:

```js
function findSolution(target) {
function find(start, history) {
if (start == target)
function find(current, history) {
if (current == target) {
return history;
else if (start > target)
} else if (current > target) {
return null;
else
return find(start + 5, “(“ + history + “ + 5)”) ||
find(start * 3, “(“ + history + “ * 3)”);
} else {
return find(current + 5, `(${history} + 5)`) ||
find(current * 3, `(${history} * 3)`);
}
}
return find(1, “1”);
return find(1, "1");
}

console.log(findSolution(24));
Expand Down