关于递归问题

function findSolution(target) {

  function find(current, history) {

    if (current == target) {

      return history;

    } else if (current > target) {

      return null;

    } else {

      return find(current + 5, `(${history} + 5)`) ||

             find(current * 3, `(${history} * 3)`);

    }

  }

  return find(1, "1");

}


console.log(findSolution(24));

为什么当到达63后current会慢慢减小,搞不懂,希望大佬解释下

我要去幼儿园深造了
浏览 829回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript