Can't wrap my head around this this recursion example [duplicate]
问题 This question already has answers here : How does this recursion work? (11 answers) Closed 4 days ago . So there is this recursion example in chap 3 of Eloquent JavaScript, it goes like this: Consider this puzzle: by starting from the number 1 and repeatedly either adding 5 or multiplying by 3, an infinite set of numbers can be produced. How would you write a function that, given a number, tries to find a sequence of such additions and multiplications that produces that number? And the given