Here's my code:
#include <iostream>
using namespace std;
int Factorial(int n)
{
int total = 1;
while(n!=0)
{
total = total * n;
n--;
}
return total;
}
int Combinations(int n, int k)
{
int count = 1;
for(int i=0; i<n; i++)
{
for(int y=0; y<(k-i); y++)
{
cout << count << " ";
count = count * Factorial(i-y)/Factorial(y+1);
}
cout << endl;
}
return count;
}
int main()
{
int numb;
cout << "Enter a number: ";
cin >> numb;
cout << " " << Combinations(numb, numb);
}
*My problem is that everytime I run my program I get this:
Enter a number: (for example) 3
1 1 0
0 0
0
0
When I thought I had coded it to look like this:
1
1 1
1 2 1
1 3 3 1
- I don't understand why it's compiling this way...And my deadline is 11pm tonight...*pulling hair*