# Further Explanation Needed

Hi Guys,

I`m kind of confused with this Recursion topic, I understand the concept, I have seen videos about it, but what confuse me really is the “multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]” that we are told in the explanation, which show that I still lack some basics understanding, because I dont know there what “multiply(arr, n - 1)” means, or how it would interact itself and why it would equall multiply(arr,n) when multiplied by arr[n - 1].

I think that if I understood that, the Recursion would be way easier to me. (The “arr[n - 1]” I get completely and the -1 purpose)

Thank you so much!

Challenge: Replace Loops using Recursion

Link to the challenge:

Just take yourself a couple of very simple cases and go through the presented recursion to understand what it is doing.

Like `multiply([1,2,3,4,5,6,7,8,9], 4)` should return `4*3*2*1 = 24`
What does the recursion do?

``````multiply([1,2,3,4,5,6,7,8,9], 4)
= multiply([1,2,3,4,5,6,7,8,9], 3) * arr
= multiply([1,2,3,4,5,6,7,8,9], 2) * arr * arr
= multiply([1,2,3,4,5,6,7,8,9], 1) * arr * arr * arr
= multiply([1,2,3,4,5,6,7,8,9], 0) * arr * arr * arr *arr
= 1 * arr * arr * arr *arr
= 1 *  4 * 3 * 2 * 1 = 24
``````
1 Like

Hi @Jagaya , thanks for taking the time and explain that to me.

What I don’t understando is in, for example:

multiply([1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9], 4)

How does the 4 interact with the numbers in the [ “” ], you’ve already given me the chart, but I still don`t understand the why behind of it.

Sorry, and thanks again.

The 4 as n is turned into a 3 (n-1) in both the recursive call multiply([1,2,3,4,5,6,7,8,9], 3), as well as in the array-adress a.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.