Question: Write a method called factorial that takes an integer parameter n and calculates n!, which is the product of the integers 1 through n. You

Write a method called factorial that takes an integer parameter n and calculates n!, which is the product of the integers 1 through n. You can use either a for loop or try recursion to write this method.

Write another method called choose that takes two integer parameters n and k that calculates and returns the n th row k th term in pascals triangle. Calculators typically have this function available on them denoted either as nCk or as n k . It is used in combinatorics to count the number of ways we can choose k objects from a set of n unique objects, so assume 0 k n. The explicit formula makes use of your factorial method:

k!/k!(n-k)!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!