Alright, so I'm having some trouble with ye olde factorials. "bool C++ beginner=true", folks. I'm struggling with this here problemo.
Here's the formula I need to compute : C(n,k) = n!/k!(n-k)!
And I have no idea how to go about this.
First, I have to implement a function for the n!. Then, I have to define a function for C(n,k), which is in the code below somewhere.
The code will ask the user to enter the size of a group of people (n) and then the size of the committee. Then it will output all possible ways to form the committee by choosing people from the given group.
???
Help would be dearly appreciated! In fact, if you're an online tutor and you need some work, don't hesitate! Use teh emails, folks! You guys rock, thanks.
Here's the skeleton of the code I made:
#include <iostream>
using namespace std;
int factorial (int number);
int combinations (int, int);
void main (void)
{
int n, k;
cout << "Enter the size of a group of people : " ;
cin >> n;
cout << "Enter the size of the committee : " ;
cin >> k;
//cout << "The choices are: ";
}
int factorial (int number)
{
if (number==0)
return 0;
else
return number*factorial(number-1);
}
int combinations (int n, int k)
{
int result;
return result;
}