Update. No problem with this question. See first comment.
I`m trying to figure out this code with jsfiddle.net, but when I run it, it triggers the actual printer attached to my computer. I changed print to "alert" http://jsfiddle.net/eZ3jQ/ and it returned (((1 * 3) + 5) * 3). However, as the return calls find, I expected it to run find over again.
Is there a way I can get the program to keep running?
function findSequence(goal) {
function find(start, history) {
if (start == goal)
return history;
else if (start > goal)
return null;
else
return find(start + 5, "(" + history + " + 5)") ||
find(start * 3, "(" + history + " * 3)");
}
return find(1, "1");
}
print(findSequence(24));