给定一个数字,程序应该返回一个仅使用 *3 或 +5 的操作序列来获取该数字,因此有两条路径可供选择。这个程序在调用自己时如何知道调用哪个函数?它如何知道每条路径调用了多少次。换句话说,我不明白如何使用OR操作员来确定find()要使用哪个调用以及每个调用有多少。
function findSequence(goal) {
    // we start at 1, and history is a string that will keep track of the operations
    function find(start, history) {
        // case when start and goal is 1.
        if (start == goal)
            return history; // return string containg 1
        // case when we build start past what we needed
        else if (start > goal)
            return null;
        else
            // Dont understand this part!
            return find(start + 5, "(" + history + " + 5)") ||
                find(start * 3, "(" + history + " * 3)");
    }
    return find(1, "1");
}
document.write(findSequence(13));