Solution Review: Pascal's Triangle
Solution review to the exercise for recursion and function composition.
We'll cover the following...
We'll cover the following...
Solution
The problem can be solved using either the function composition or recursion. Let’s look at the two approaches individually.
Recursion approach
For this solution, factor out the base cases and recursion cases.
The two cases can be outlined like this.
- Base case (lines 2 to 7): For zeroth line, the array will only have a single value of
1, so we can conclusively return[1]. - Recursive case (lines 8 to 24): For any other line, we have a value of
1at