The main culprit:
return find(start + 5, "(" + history + " + 5)") ||
find(start * 3, "(" + history + " * 3)");
, start 1 , , - 13.
find() . A.find() start 1 + 5 (6). Find B.- B
start 6 + 5 (11). Find C. - C
start 11 + 5 (16). Find D. - D
null C. - C OR .
find() start 6 * 3 (18). Find E.
, ?
- E, , , Find D
null C. - C
null B. - B OR .
, Find A , null, , Find A , , findSolution() .
null find(). null - false. ( history ), find(). history, , , , "", findSolution().
JavaScript.
var findIteration = 0;
function findSolution(target) {
function find(start, history, caller) {
var thisIteration = ++findIteration;
console.log("Find Iteration " + thisIteration, "Start: " + start, "Called by: " + caller);
if (start == target)
return history;
else if (start > target)
return null;
else
return find(start + 5, "(" + history + " + 5)", thisIteration) ||
find(start * 3, "(" + history + " * 3)", thisIteration);
}
return find(1, "1", 0);
}
console.log(findSolution(13));
Hide result:

"" find(), - , Find C ( 3) Find E ( 5) , .
, find() 9 , , , .