Solution Review: Pascal's Triangle
This review provides a detailed analysis of the solution to the Pascal's Triangle problem.
We'll cover the following...
Solution: Using Recursion
Press + to interact
def printPascal(testVariable) :# Base Caseif testVariable == 0 :return [1]else :line = [1]# Recursive CasepreviousLine = printPascal(testVariable - 1)for i in range(len(previousLine) - 1):line.append(previousLine[i] + previousLine[i + 1])line += [1]return line# Driver CodetestVariable = 5print(printPascal(testVariable))
Explanation:
In the code snippet above, we use the values of the previous function call to calculate the values of the current function call. If we reach the ...