Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MatLab please using recursion/ one function only. Thank you! Pascal's triangle is an arrangement of numbers such that each row is equivalent to the coefficients

MatLab please using recursion/ one function only. Thank you!

image text in transcribed

Pascal's triangle is an arrangement of numbers such that each row is equivalent to the coefficients of the binomial expansion of (x+y)(p1), where p is some positive integer more than or equal to 1 . For example, (x+y)2=1x2+2xy+1y2 so the third row of Pascal's triangle is 121 . Let Rm represent the m-th row of Pascal's triangle, and Rm(n) be the n-th element of the row. By definition, Rm has m elements, and Rm(1)=Rm(n)=1. The remaining elements are computed by the following recursive relationship: Rm(i)=Rm1(i1)+Rm1(i) for i=2,,m1. The first few rows of Pascal's triangle are depicted in the following figure. You may assume that m is a strictly positive integer. The output variable, row, must be a row vector. \[ \begin{array}{cccccc} \multicolumn{6}{c}{1} \\ & & \\ & 1 & 2 & 1 \\ & 1 & 3 & 3 & 1 \\ 1 & 4 & 6 & 4 & 1 \\ 1 & 5 & 10 & 10 & 5 & 1 \end{array} \] Write a function with header [ row ]= myPascalRow (m) where row is the m-th row of the Pascal triangle. You may assume that m is a strictly positive integer. Test Cases

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions