Question: Python Question 5. Recursive Functions 20 points) The following function uses recursion to generate the nth row of Pascal's triangle: 2 1 1 5 10
5. Recursive Functions 20 points) The following function uses recursion to generate the nth row of Pascal's triangle: 2 1 1 5 10 10 51 In I: def pascal (n): if n1: return [1] else: p-line = pascal (n-1) line = [ p-line [i] +p-line [i+1] line.insert (0,1) line.append (1) for i in range (len (pline)-1)] return line print (pascal (6)) Rewrite the above function to use iteration (using only while or for loops) instead of recursion
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
