Description
The binomial coefficient n
k
(read ”n choose k”) is defined as
n
k
=
n!
(n − k)!k!
where ! is the factorial symbol, (e.g., 4! = 4*3*2*1 = 24, 0! = 1! = 1) and n and
k are non-negative integers with n > k.
(1) Write a function called mybinomial.m that calculates n choose k without
using MATLAB’s built-in binomial or factorial functions. This will involve
multiple loops. Your script should include if-statements that return an
error if n is less than k OR if either n or k is negative. You can assume
that the user will use integers for n and k.
(2) Test your function with the following inputs.
n = 10, k = 2
n = 5, k = −3
n = 9, k = 13
HW GUIDELINES
• Submit your PDF files containing successful execution of the code (using
the tests given in the problem).
• Put your first and last name on the first line of the code.
• Remember that m-files should be commented so that a reader would know
what the program/function does.
• Remember to suppress output and only show output where appropriate in
the PDF file.

