Recursion: multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]

Hello,
Just to confirm that I well understood:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion


in order to explain:
multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1]

“n = 3” : is the number of first elementss… of one array.
arr[n-1] is equivalent to arr[i] in relation to “n”.
thus:
mutiply(arr, 3) == multiply(arr, 2) * arr[2].

is equal to :
mutiply(arr, 3) == (2*3) * 4

is there a mistake ?

1 Like

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