The formula for computing the number of ways of choosing r different things from
ID: 3821802 • Letter: T
Question
The formula for computing the number of ways of choosing r different things from a set of ft things (the number of/--combinations) is the following: C (n, r) = n!/r! (n - r)! In this formula, the factorial function is represented by an exclamation point (!) and defined as the product: n! = n = (n - 1) middot (n - 2) middot... middot 1 Discover a recursive version of the C(n, r) formula and write a recursive method that computes the values of the formula. The name of the method should be combinations.Explanation / Answer
#include int fact(int z); void main() { int n, r, ncr; printf(" Enter the value for N and R "); scanf("%d%d", &n, &r); ncr = fact(n) / (fact(r) * fact(n - r)); printf(" The value of ncr is: %d", ncr); } int fact(int z) { int f = 1, i; if (z == 0) { return(f); } else { for (i = 1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.