Factorials. The following set of problems relates to computing factorials. If you did not cover the section on recursion, read the material on pages 200–201 for the definition of a factorial and then review the nonrecursive function for computing the factorial.
Whereas permutations (Problem) are concerned with order, combinations are not. Thus, given n distinct objects, there is only one combination of n objects taken n at a time, but there are n! permutations of n distinct objects taken n at a time. The number of combinations of n objects, taken k at a time is equal to n!/((k!)(n ‒ k)!). Write a function named combine that receives values for n and k and then returns the number of combinations of the n objects taken k at a time. (If we consider the set of digits {1,2,3}, the different combinations of two digits are {1,2},{1,3} and {2,3} Assume that the corresponding prototype is
int combine(int n, int k);
Problem
Factorials. The following set of problems relates to computing factorials. If you did not cover the section on recursion, read the material on pages 200–201 for the definition of a factorial and then review the nonrecursive function for computing the factorial.
Suppose that we have n distinct objects. There are many different orders that we can select to line up the objects in a row. In fact, there are n! orderings, or permutations, that can be obtained with n objects. If we have n objects, and select k of the objects, then there are n!/(n ‒ k)! possible orderings of k objects. That is, the number of different permutations of n different objects taken k at a time is n!/(n ‒ k)!.Write a function named permute that receives values for n and k, and then returns the number of permutations of the n objects taken k at a time. (If we consider the set of digits {1,2,3}, the different permutations of two digits are {1,2},{2,1},{1,3},{3,1},{2,3} and {3,2} Assume that the corresponding prototype is
int permute(int n,int k);
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.