Each of the terms inPascal’s Triangle can be generated using the combinatoricsformula. Your job is to write a MatLab function called Cterm whichcalculates one of these terms. The function should accept 2arguments: n and r. The output of the function should be C( n , r). Then write a program which does the following. The user shouldenter a start row and an end row for Pascal’s Triangle. Theprogram should then generate a file called
‘Ptable.txt’ which displays the start row, the end row,and all the rows in between. You must use the function
Cterm in your program.
The name of this program must be Pascal.m, the name of the program which definesthe combinatorics
function must be Cterm.m, and the file containing the output mustbe called Ptable.txt
The output should look EXACTLY as shown below:
Example output for Part B:
>> Pascal
Enter the first row number: 4
Enter the last row number: 7
The file Ptable.txt will look EXACTLY like the following:
Row 4 of Pascal’s Triangle:
1 4 6 4 1
Row 5 of Pascal’s Triangle:
1 5 10 10 5 1
Row 6 of Pascal’s Triangle:
1 6 15 20 15 6 1
Row 7 of Pascal’s Triangle:
1 7 21 35 35 21 71

Want an answer?

No answer yet. Submit this
question to the community.